Index: trunk/psphot/src/psphotStackMatchPSFs.c
===================================================================
--- trunk/psphot/src/psphotStackMatchPSFs.c	(revision 34136)
+++ trunk/psphot/src/psphotStackMatchPSFs.c	(revision 34352)
@@ -4,4 +4,6 @@
 {
     bool status = true;
+
+    psLogMsg ("psphot", PS_LOG_INFO, "--- psphotStack Match PSFs ---");
 
     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, "PSPHOT"); 
@@ -44,5 +46,5 @@
     }
 
-    // loop over the available readouts (ignore chisq image)
+    // loop over the available readouts (ignore chisq image)psLogMsg ("psphot", PS_LOG_INFO, "--- psphot Source Stats ---");
     for (int i = 0; i < num; i++) { 
 	if (!psphotStackMatchPSFsReadout (config, view, options, i)) {
@@ -57,9 +59,11 @@
 
 // convolve the image to match desired PSF
-// XXX is this code consistent with 'convolve' = false?
+// XXX is this code consistent with 'convolve' = false?  XXX: No
 bool psphotStackMatchPSFsReadout (pmConfig *config, const pmFPAview *view, psphotStackOptions *options, int index) {
 
     psImageMaskType maskValue;
     psImageMaskType markValue;
+
+    psLogMsg("psphot", PS_LOG_DETAIL, "-- starting PSF matching for readout %d --", index);
 
     // get the PSPHOT.MASK value from the config
@@ -102,4 +106,20 @@
 	saveMatchData(readoutOut, options, index);
     }
+    bool notMatched = psMetadataLookupBool(NULL, readoutOut->analysis, "NOT.PSF.MATCHED");
+    if (notMatched) {
+        if (!readoutOut->image) {
+            // our images got freed in the matching process. Recreate them so that they
+            // are available when sources are copied to this readout.
+            readoutOut->image = psImageCopy(NULL, readoutSrc->image, PS_TYPE_F32);
+            if (readoutSrc->variance) {
+                psFree(readoutOut->variance);
+                readoutOut->variance = psImageCopy(NULL, readoutSrc->variance, PS_TYPE_F32);
+            }
+            if (readoutSrc->mask) {
+                psFree(readoutOut->mask);
+                readoutOut->mask = psImageCopy(NULL, readoutSrc->mask, PS_TYPE_IMAGE_MASK);
+            }
+        }
+    }
 
     // renormalize the stack variances to have sigma = 1.0
@@ -111,11 +131,10 @@
     // save the output fwhm values in the readout->analysis.  we may have / will have multiple output PSF sizes,
     // so we save this in a vector.  if the vector is not yet defined, create it
-    // Skip this if the readout deconvolution fraction was over the limit.
+    // Skip this if psf matching failed for this readout. For example if deconvolution fraction was over the limit.
     // NOTE: fwhmValues as defined here has 1 + nMatched PSF : 0 == unmatched
     psVector *fwhmValues = psVectorAllocEmpty(10, PS_TYPE_F32);
     psVectorAppend(fwhmValues, NAN); // XXX this corresponds to the unmatched image set
 
-    bool overLimit = psMetadataLookupBool(NULL, readoutOut->analysis, "DECONV.OVERLIMIT");
-    if (!overLimit) {
+    if (!notMatched) {
         for (int i = 0; i < options->targetSeeing->n; i++) {
             psVectorAppend(fwhmValues, options->targetSeeing->data.F32[i]);
@@ -124,5 +143,5 @@
     psMetadataAddVector(readoutSrc->analysis, PS_LIST_TAIL, "STACK.PSF.FWHM.VALUES", PS_META_REPLACE, "PSF sizes", fwhmValues);
     psMetadataAddVector(readoutOut->analysis, PS_LIST_TAIL, "STACK.PSF.FWHM.VALUES", PS_META_REPLACE, "PSF sizes", fwhmValues);
-    psFree(fwhmValues); // drops the extra copy
+    psFree(fwhmValues); // drops this function's reference
 
     return true;
