Index: branches/eam_branches/relastro.20100326/src/ImageOps.c
===================================================================
--- branches/eam_branches/relastro.20100326/src/ImageOps.c	(revision 27487)
+++ branches/eam_branches/relastro.20100326/src/ImageOps.c	(revision 27488)
@@ -286,4 +286,7 @@
   Coords *moscoords, *imcoords;
 
+  // check if this image is bad and should be skipped
+  if (badCoords(im)) return;
+
   moscoords = NULL;
   mosaic = getMosaicForImage (im);
@@ -292,4 +295,10 @@
   }
   imcoords = &image[im].coords;
+
+  // accumulate the rms position offsets.  if this value, or any specific entry, is too
+  // large, we will reset the image to the original coords at the end of the analysis
+
+  dPos = 0.0;
+  nPos = 0;
 
   for (i = 0; i < Nlist[im]; i++) {
@@ -317,13 +326,16 @@
 
     if (fabs(catalog[c].measure[m].dR - dR) > 10.0) {
-      // XXXXX running into this still for last megacam exposure: wrong mosaic?
-      // ???? inconsistently hitting this????
       fprintf (stderr, "!");
-      // abort ();
+      setBadCoords (im); // report a failure for this image
+      return;
     }
     if (fabs(catalog[c].measure[m].dD - dD) > 10.0) {
       fprintf (stderr, "*");
-      // abort ();
-    }
+      setBadCoords (im); // report a failure for this image
+      return;
+    }
+
+    dPos += SQ(catalog[c].measure[m].dR - dR) + SQ(catalog[c].measure[m].dD - dD);
+    nPos ++;
 
     catalog[c].measure[m].dR = dR;
@@ -341,4 +353,7 @@
     }
   }
+
+  saveOffsets (dPos, nPos, im);
+
   return;
 }
