Index: trunk/Ohana/src/relastro/src/RepairWarpMeasures.c
===================================================================
--- trunk/Ohana/src/relastro/src/RepairWarpMeasures.c	(revision 39602)
+++ trunk/Ohana/src/relastro/src/RepairWarpMeasures.c	(revision 39603)
@@ -127,5 +127,5 @@
     // NOTE: this actually works surprisingly well near the pole
     double dPos = hypot(dR,dD);
-    if (dPos < 2.0) { 
+    if (dPos < 3.0) { 
       // image coord agrees with average coord
       if (coordsDiffer) {
@@ -146,6 +146,6 @@
 	fprintf (stderr, "inconsistent warp measurement times: %d vs %d for %f, %f (%d, %ld)", measure->t, image[im].tzero, Rwrp, Dwrp, measure->photcode, extID); 
 	result.NbadWarpTime ++;
-	continue;
-      }
+      }
+      continue;
     }
 
Index: trunk/Ohana/src/relastro/src/RepairWarps.c
===================================================================
--- trunk/Ohana/src/relastro/src/RepairWarps.c	(revision 39602)
+++ trunk/Ohana/src/relastro/src/RepairWarps.c	(revision 39603)
@@ -90,6 +90,14 @@
 
     // save backup of original cpm file
-    if (!dvo_catalog_backup (&catalog, "rp0", TRUE)) {
-      fprintf (stderr, "ERROR: failed to make backup for catalog %s\n", catalog.filename);
+    if (!dvo_catalog_unlock (catalog.measure_catalog)) {
+      fprintf (stderr, "ERROR: failed to unlock cpm table for catalog %s\n", catalog.filename);
+      exit (1);
+    }
+    if (!dvo_catalog_backup (catalog.measure_catalog, ".rp2", FALSE)) {
+      fprintf (stderr, "ERROR: failed to make backup cpm table for catalog %s\n", catalog.filename);
+      exit (1);
+    }
+    if (!dvo_catalog_lock (catalog.measure_catalog, catalog.lockmode)) {
+      fprintf (stderr, "failed to re-lock cpm table catalog file %s\n", catalog.filename);
       exit (1);
     }
Index: trunk/Ohana/src/relastro/src/WarpImageMaps.c
===================================================================
--- trunk/Ohana/src/relastro/src/WarpImageMaps.c	(revision 39602)
+++ trunk/Ohana/src/relastro/src/WarpImageMaps.c	(revision 39603)
@@ -123,4 +123,8 @@
     ALLOCATE (warpgroup[i].onBoundary, int, warpgroup[i].Nwarps);
 
+    if (i == 54950) {
+      fprintf (stderr, "checking problem warpgroup\n");
+    }
+
     for (int j = 0; j < warpgroup[i].Nwarps; j++) {
 
@@ -178,10 +182,35 @@
 
       if (warpgroup[i].Rmax[j] - warpgroup[i].Rmin[j] > 270.0) {
-	// Rmin and Rmax are in the range 0 - 360.  For images at the 0,360 boundary,
-	// "Rmax" is the lower edge, and "Rmin" is the upper edge.  we need to flip them 
-	// and then break the 0-360 range:
-	double tmp = warpgroup[i].Rmin[j];
-	warpgroup[i].Rmin[j] = warpgroup[i].Rmax[j] - 360.0;
-	warpgroup[i].Rmax[j] = tmp;
+	// Rmin and Rmax are in the range 0 - 360.  For images at the 0,360 boundary, we need to recalculated Rmin,Rmax 
+	// using 0.0 as the midpoint (allowing the range -180 to +180)
+
+	XY_to_RD (&R, &D, 0.0, 0.0, &image[N].coords);
+	R = ohana_normalize_angle_to_midpoint(R, 0.0);
+	warpgroup[i].Rmin[j] = R;
+	warpgroup[i].Rmax[j] = R;
+	warpgroup[i].Dmin[j] = D;
+	warpgroup[i].Dmax[j] = D;
+
+	XY_to_RD (&R, &D, Nx, 0.0, &image[N].coords);
+	R = ohana_normalize_angle_to_midpoint(R, 0.0);
+	warpgroup[i].Rmin[j] = MIN (warpgroup[i].Rmin[j], R);
+	warpgroup[i].Rmax[j] = MAX (warpgroup[i].Rmax[j], R);
+	warpgroup[i].Dmin[j] = MIN (warpgroup[i].Dmin[j], D);
+	warpgroup[i].Dmax[j] = MAX (warpgroup[i].Dmax[j], D);
+	
+	XY_to_RD (&R, &D, 0.0, Ny, &image[N].coords);
+	R = ohana_normalize_angle_to_midpoint(R, 0.0);
+	warpgroup[i].Rmin[j] = MIN (warpgroup[i].Rmin[j], R);
+	warpgroup[i].Rmax[j] = MAX (warpgroup[i].Rmax[j], R);
+	warpgroup[i].Dmin[j] = MIN (warpgroup[i].Dmin[j], D);
+	warpgroup[i].Dmax[j] = MAX (warpgroup[i].Dmax[j], D);
+
+	XY_to_RD (&R, &D, Nx, Ny, &image[N].coords);
+	R = ohana_normalize_angle_to_midpoint(R, 0.0);
+	warpgroup[i].Rmin[j] = MIN (warpgroup[i].Rmin[j], R);
+	warpgroup[i].Rmax[j] = MAX (warpgroup[i].Rmax[j], R);
+	warpgroup[i].Dmin[j] = MIN (warpgroup[i].Dmin[j], D);
+	warpgroup[i].Dmax[j] = MAX (warpgroup[i].Dmax[j], D);
+
 	warpgroup[i].onBoundary[j] = TRUE;
       }
