Index: /branches/eam_branches/ipp-20100823/psModules/src/imcombine/pmSubtractionEquation.c
===================================================================
--- /branches/eam_branches/ipp-20100823/psModules/src/imcombine/pmSubtractionEquation.c	(revision 29125)
+++ /branches/eam_branches/ipp-20100823/psModules/src/imcombine/pmSubtractionEquation.c	(revision 29126)
@@ -1286,12 +1286,18 @@
     float dmin = 0.0;
 
+    // XXX update these with a bit more rigour
     for (int y = - footprint; y <= footprint; y++) {
         for (int x = - footprint; x <= footprint; x++) {
-            float dflux = 0.5*(target->kernel[y][x] + source->kernel[y][x] * norm);
-            if (dflux < 0.02*sum) continue;
+	  // float dflux = 0.5*(target->kernel[y][x] + source->kernel[y][x] * norm);
+            // if (dflux < 0.02*sum) continue;
             dflux1 += residual->kernel[y][x];
             dflux2 += PS_SQR(residual->kernel[y][x]);
-            dmax = PS_MAX(residual->kernel[y][x], dmax);
-            dmin = PS_MIN(residual->kernel[y][x], dmin);
+            // dmax = PS_MAX(residual->kernel[y][x], dmax);
+            // dmin = PS_MIN(residual->kernel[y][x], dmin);
+            dmax += fabs(residual->kernel[y][x]);
+
+	    if (hypot(x,y) > 2.0) {
+	      dmin += fabs(residual->kernel[y][x]);
+	    }
             npix ++;
         }
@@ -1303,8 +1309,8 @@
     if (!isfinite(peak)) return false;
 
-    // fprintf (stderr, "sum: %f, peak: %f, sigma: %f, fsigma: %f, fmax: %f, fmin: %f\n", sum, peak, sigma, sigma/sum, dmax/peak, dmin/peak);
+    fprintf (stderr, "sum: %f, peak: %f, sigma: %f, fsigma: %f, fmax: %f, fmin: %f\n", sum, peak, sigma, sigma/sum, dmax/sum, dmin/sum);
     psVectorAppend(fSigRes, sigma/sum);
-    psVectorAppend(fMaxRes, dmax/peak);
-    psVectorAppend(fMinRes, dmin/peak);
+    psVectorAppend(fMaxRes, dmax/sum);
+    psVectorAppend(fMinRes, dmin/sum);
     return true;
 }
Index: /branches/eam_branches/ipp-20100823/psModules/src/imcombine/pmSubtractionStamps.c
===================================================================
--- /branches/eam_branches/ipp-20100823/psModules/src/imcombine/pmSubtractionStamps.c	(revision 29125)
+++ /branches/eam_branches/ipp-20100823/psModules/src/imcombine/pmSubtractionStamps.c	(revision 29126)
@@ -96,4 +96,6 @@
 
     // fprintf (stderr, "xMin, xMax: %d, %d -> ", xMin, xMax);
+    float xRaw = xMin;
+    float yRaw = yMin;
 
     // Ensure we're not going to go outside the bounds of the image
@@ -103,6 +105,12 @@
     yMax = PS_MIN(numRows - border - 1, yMax);
 
-    if (xMax < xMin) return false;
-    if (yMax < yMin) return false;
+    if (xMax < xMin) {
+      fprintf (stderr, "%f,%f : x-border\n", xRaw, yRaw);
+      return false;
+    }
+    if (yMax < yMin) {
+      fprintf (stderr, "%f,%f : y-border\n", xRaw, yRaw);
+      return false;
+    }
 
     psAssert (xMin <= xMax, "x mismatch?");
@@ -118,4 +126,5 @@
             if (subMask && subMask->data.PS_TYPE_IMAGE_MASK_DATA[y][x] &
                 (PM_SUBTRACTION_MASK_BORDER | PM_SUBTRACTION_MASK_REJ)) {
+	      fprintf (stderr, "%f,%f : masked\n", xRaw, yRaw);
                 return false;
             }
@@ -133,4 +142,7 @@
     }
 
+    if (!found) {
+      fprintf (stderr, "%f,%f : fails flux test\n", xRaw, yRaw);
+    }
     return found;
 }
@@ -431,4 +443,5 @@
                 // Take stamps off the top of the (sorted) list
                 for (int j = xList->n - 1; j >= 0 && !goodStamp; j--) {
+		  fprintf (stderr, "%d : xList: %ld elements\n", i, xList->n);
                     // Chop off the top of the list
                     xList->n = j;
Index: /branches/eam_branches/ipp-20100823/psModules/src/imcombine/pmSubtractionVisual.c
===================================================================
--- /branches/eam_branches/ipp-20100823/psModules/src/imcombine/pmSubtractionVisual.c	(revision 29125)
+++ /branches/eam_branches/ipp-20100823/psModules/src/imcombine/pmSubtractionVisual.c	(revision 29126)
@@ -286,4 +286,6 @@
         return false;
     }
+
+    // XXX clear the overlay(s) (red at least!)
 
     // get the kernel sizes
