Index: /tags/ipp-20110218/psModules/src/imcombine/pmSubtraction.c
===================================================================
--- /tags/ipp-20110218/psModules/src/imcombine/pmSubtraction.c	(revision 30740)
+++ /tags/ipp-20110218/psModules/src/imcombine/pmSubtraction.c	(revision 30741)
@@ -939,4 +939,14 @@
     // which are significantly deviant from that distribution.
 
+    // if we only have 3 or fewer stars, we have to accept them all
+    if (match->nGood < 3) {
+	kernels->mean = NAN;
+	kernels->rms = NAN;
+	kernels->numStamps = match->nGood;
+	
+	psLogMsg("psModules.imcombine", PS_LOG_INFO, "only %d stars, keeping them all (good luck!)",  kernels->numStamps);
+	return 0;
+    }
+
     kernels->mean = NAN;
     kernels->rms = NAN;
Index: /tags/ipp-20110218/psModules/src/imcombine/pmSubtractionMatch.c
===================================================================
--- /tags/ipp-20110218/psModules/src/imcombine/pmSubtractionMatch.c	(revision 30740)
+++ /tags/ipp-20110218/psModules/src/imcombine/pmSubtractionMatch.c	(revision 30741)
@@ -667,4 +667,5 @@
             }
 
+	    int nTries = 0;
 	    bool tryAgain = true;
 	    while (tryAgain) {
@@ -677,7 +678,15 @@
 
 		// generate the window function from the set of stamps
+		// we attempt to set the window based on the measured kron radius, but the
+		// initial guess may be too small. allow the window to grow if the kron radius
+		// implies the need for a larger windon.  But only allow 2 additional tries
 		if (!pmSubtractionStampsGetWindow(&tryAgain, stamps, size)) {
 		    // if we failed, it might be due to the desired normWindow being larger than the current footprint.
 		    // in this case, just adjust the footprint and try again.
+		    if (tryAgain && (nTries >= 2)) {
+			// unrecoverable error
+			psError(PM_ERR_STAMPS, true, "Unable to get stamp window (failure to converge).");
+			goto MATCH_ERROR;
+		    }
 		    if (tryAgain) {
 			// keep the border constant
@@ -688,6 +697,7 @@
 			// we need to reconstruct everything, so just free the stamps here and retry
 			psFree(stamps);
+			nTries ++;
 		    } else {
-			// unrecoverable error
+			// unrecoverable error generated in pmSubtractionStampsGetWindow
 			psError(psErrorCodeLast(), false, "Unable to get stamp window.");
 			goto MATCH_ERROR;
Index: /tags/ipp-20110218/psModules/src/imcombine/pmSubtractionStamps.c
===================================================================
--- /tags/ipp-20110218/psModules/src/imcombine/pmSubtractionStamps.c	(revision 30740)
+++ /tags/ipp-20110218/psModules/src/imcombine/pmSubtractionStamps.c	(revision 30741)
@@ -913,4 +913,14 @@
 	psFree (norm2);
 	return false; 
+    }
+
+    if (!isfinite(R1) || !isfinite(R2)) {
+        psError(PM_ERR_STAMPS, true, "Kron Radii are not finite (failure to converge).");
+	psFree (stats);
+	psFree (flux1);
+	psFree (flux2);
+	psFree (norm1);
+	psFree (norm2);
+        return false;
     }
 
Index: /tags/ipp-20110218/psModules/src/imcombine/pmSubtractionVisual.c
===================================================================
--- /tags/ipp-20110218/psModules/src/imcombine/pmSubtractionVisual.c	(revision 30740)
+++ /tags/ipp-20110218/psModules/src/imcombine/pmSubtractionVisual.c	(revision 30741)
@@ -292,5 +292,8 @@
         type = im->type.type;
     }
-    if (imageMax == -1) return false;
+    if (imageMax == -1) {
+	psFree (matrixNorm);
+	return false;
+    }
 
     int border = 15;
@@ -350,4 +353,5 @@
     psFree(canvas);
     psFree(canvas32);
+    psFree (matrixNorm);
     return true;
 }
@@ -503,4 +507,5 @@
 	    psFitsClose(fits);
 	}
+	psFree (output);
     }
 	
@@ -710,7 +715,9 @@
 	    pmSubtractionVisualShowFitAddStamp (image2, image1, residual, background, norm, i);
 	}
+	psFree(polyValues);
     }
     pmSubtractionVisualShowFitImage(norm);
 
+    psFree (residual);
     return true;
 }
@@ -1029,4 +1036,8 @@
     KapaPlotVector (kapa3, lflx->n, lMxx->data.F32, "y");
 
+    psFree (lflx);
+    psFree (lchi);
+    psFree (lMxx);
+
     pmVisualAskUser(NULL);
     return true;
