Index: branches/eam_branches/ipp-20230313/psModules/src/detrend/pmNewNonLinear.c
===================================================================
--- branches/eam_branches/ipp-20230313/psModules/src/detrend/pmNewNonLinear.c	(revision 42511)
+++ branches/eam_branches/ipp-20230313/psModules/src/detrend/pmNewNonLinear.c	(revision 42528)
@@ -39,5 +39,5 @@
 	    // Calculate correction factor contribution for this pixel.
 	    psF32 flux = image->data.F32[i][j];
-	    psF32 lFlux = log10(flux);
+	    psF32 lFlux = (flux > 1.0) ? log10(flux) : 0.0; // do not introduce NANs for negative flux
 	    
 	    psF32 factor = psSpline1DEval (model, lFlux);
Index: branches/eam_branches/ipp-20230313/psModules/src/imcombine/pmSubtractionKernels.c
===================================================================
--- branches/eam_branches/ipp-20230313/psModules/src/imcombine/pmSubtractionKernels.c	(revision 42511)
+++ branches/eam_branches/ipp-20230313/psModules/src/imcombine/pmSubtractionKernels.c	(revision 42528)
@@ -1361,6 +1361,11 @@
     }
 
-    return pmSubtractionKernelsGenerate(type, size, spatialOrder, fwhms, orders, inner, binning,
-                                        ringsOrder, penalty, bounds, mode);
+    pmSubtractionKernels *outKernel = pmSubtractionKernelsGenerate(type, size, spatialOrder,
+								  fwhms, orders, inner, binning,
+								  ringsOrder, penalty, bounds, mode);
+    psFree (fwhms);
+    psFree (orders);
+
+    return outKernel;
 }
 
Index: branches/eam_branches/ipp-20230313/psModules/src/objects/pmSourceMatch.c
===================================================================
--- branches/eam_branches/ipp-20230313/psModules/src/objects/pmSourceMatch.c	(revision 42511)
+++ branches/eam_branches/ipp-20230313/psModules/src/objects/pmSourceMatch.c	(revision 42528)
@@ -219,4 +219,7 @@
                                       sources); // Number of sources
 
+        // an input image with only poor detections can cause trouble, remove it
+        if (!numSources) continue;
+
         if (!boundsMaster) {
             // First run through --- can just copy
