Index: trunk/ppSub/src/ppSubLoop.c
===================================================================
--- trunk/ppSub/src/ppSubLoop.c	(revision 30040)
+++ trunk/ppSub/src/ppSubLoop.c	(revision 30066)
@@ -36,4 +36,6 @@
     psAssert(config, "Require configuration.");
 
+    bool success = true;
+
     pmConfigCamerasCull(config, NULL);
     pmConfigRecipesCull(config, "PPSUB,PPSTATS,PSPHOT,PSASTRO,MASKS,JPEG");
@@ -61,5 +63,6 @@
 	if (!ppSubInputDetections(&foundDetections, "PPSUB.POS1.SOURCES", "PPSUB.INPUT", data)) {
 	    psError(psErrorCodeLast(), false, "Unable to measure positive detections (1)");
-	    return false;
+	    success = false;
+            goto ESCAPE;
 	}
 	// if nothing was found, don't bother doing the forced photometry below
@@ -90,5 +93,6 @@
             psMetadataAddF32(recipe, PS_LIST_TAIL, "PEAKS_NSIGMA_LIMIT", PS_META_REPLACE, "", nsigma_peak_save);
             psMetadataAddStr(recipe, PS_LIST_TAIL, "BREAK_POINT", PS_META_REPLACE, "", breakPt_save);
-	    return false;
+	    success = false;
+            goto ESCAPE;
 	}
         psMetadataAddF32(recipe, PS_LIST_TAIL, "PEAKS_NSIGMA_LIMIT", PS_META_REPLACE, "", nsigma_peak_save);
@@ -101,17 +105,20 @@
     }
 
-    // XXX if it exists, use the POS1, POS2 results for the FWHMs
+    // XXX if it exists, use the POS1, POS2 successs for the FWHMs
     if (!ppSubMatchPSFs(data)) {
         psError(psErrorCodeLast(), false, "Unable to match PSFs.");
-        return false;
+        success = false;
+        goto ESCAPE;
     }
     if (data->quality) {
         // Can't do anything at all
-        return true;
+        success = false;
+        goto ESCAPE;
     }
     // generate the residual stamp grid for visualization
     if (!ppSubResidualSampleJpeg(config)) {
         psError(psErrorCodeLast(), false, "Unable to update.");
-        return false;
+        success = false;
+        goto ESCAPE;
     }
 
@@ -125,10 +132,12 @@
     if (!ppSubFilesIterateUp(config, PPSUB_FILES_INPUT)) {
         psError(PPSUB_ERR_IO, false, "Unable to close input files.");
-        return false;
+        success = false;
+        goto ESCAPE;
     }
 
     if (!ppSubLowThreshold(data)) {
         psError(psErrorCodeLast(), false, "Unable to threshold images.");
-        return false;
+        success = false;
+        goto ESCAPE;
     }
 
@@ -136,15 +145,18 @@
     if (!ppSubFilesIterateDown(config, PPSUB_FILES_SUB)) {
         psError(PPSUB_ERR_IO, false, "Unable to set up subtraction files.");
-        return false;
+        success = false;
+        goto ESCAPE;
     }
 
     if (!ppSubDefineOutput("PPSUB.OUTPUT", config)) {
         psError(psErrorCodeLast(), false, "Unable to define output.");
-        return false;
+        success = false;
+        goto ESCAPE;
     }
 
     if (!data->quality && !ppSubMakePSF(data)) {
         psError(psErrorCodeLast(), false, "Unable to generate PSF.");
-        return false;
+        success = false;
+        goto ESCAPE;
     }
 
@@ -161,5 +173,6 @@
     if (!ppSubReadoutSubtract(config)) {
         psError(psErrorCodeLast(), false, "Unable to subtract images.");
-        return false;
+        success = false;
+        goto ESCAPE;
     }
     // dumpout(config, "diff.1.fits");
@@ -168,5 +181,6 @@
     if (!ppSubFilesIterateUp(config, PPSUB_FILES_PSF | PPSUB_FILES_CONV)) {
         psError(PPSUB_ERR_IO, false, "Unable to close input files.");
-        return false;
+        success = false;
+        goto ESCAPE;
     }
     // dumpout(config, "diff.2a.fits");
@@ -175,5 +189,6 @@
     if (!ppSubBackground(config)) {
         psError(psErrorCodeLast(), false, "Unable to subtract background.");
-        return false;
+        success = false;
+        goto ESCAPE;
     }
     // dumpout(config, "diff.2b.fits");
@@ -182,5 +197,6 @@
     if (!ppSubVarianceRescale(config, data)) {
         psError(psErrorCodeLast(), false, "Unable to rescale variance.");
-        return false;
+        success = false;
+        goto ESCAPE;
     }
     // dumpout(config, "diff.2c.fits");
@@ -188,15 +204,18 @@
     if (data->quality) {
         // Done all we can do up to this point
-        return true;
+        success = false;
+        goto ESCAPE;
     }
 
     if (!ppSubFilesIterateDown(config, PPSUB_FILES_PHOT_SUB)) {
         psError(PPSUB_ERR_IO, false, "Unable to set up photometry files.");
-        return false;
+        success = false;
+        goto ESCAPE;
     }
 
     if (!data->quality && !ppSubReadoutPhotometry("PPSUB.OUTPUT", data)) {
         psError(psErrorCodeLast(), false, "Unable to perform photometry.");
-        return false;
+        success = false;
+        goto ESCAPE;
     }
     // dumpout(config, "diff.3.fits");
@@ -206,5 +225,6 @@
 	if (!ppSubReadoutForcedPhot("PPSUB.FORCED1.SOURCES", "PPSUB.OUTPUT", "PPSUB.POS1.SOURCES", data)) {
 	    psError(psErrorCodeLast(), false, "Unable to perform photometry.");
-	    return false;
+	    success = false;
+            goto ESCAPE;
 	}
     }
@@ -214,5 +234,6 @@
 	if (!ppSubReadoutForcedPhot("PPSUB.FORCED2.SOURCES", "PPSUB.OUTPUT", "PPSUB.POS2.SOURCES", data)) {
 	    psError(psErrorCodeLast(), false, "Unable to perform photometry.");
-	    return false;
+	    success = false;
+            goto ESCAPE;
 	}
     }
@@ -220,5 +241,6 @@
     if (!ppSubFilesIterateUp(config, PPSUB_FILES_PHOT_SUB)) {
         psError(PPSUB_ERR_IO, false, "Unable to set up photometry files.");
-        return false;
+        success = false;
+        goto ESCAPE;
     }
 
@@ -226,5 +248,6 @@
     if (!ppSubReadoutStats(data)) {
         psError(psErrorCodeLast(), false, "Unable to collect statistics");
-        return false;
+        success = false;
+        goto ESCAPE;
     }
     // Do Mask Stats
@@ -233,5 +256,6 @@
       if (!ppSubMaskStats(config, view,data->stats)) {
 	psError(psErrorCodeLast(), false, "Unable to generate mask statistics");
-	return(false);
+	success = false;
+        goto ESCAPE;
       }
     }
@@ -241,5 +265,6 @@
     if (!ppSubReadoutJpeg(config)) {
         psError(psErrorCodeLast(), false, "Unable to update.");
-        return false;
+        success = false;
+        goto ESCAPE;
     }
 
@@ -248,15 +273,18 @@
         if (!ppSubFilesIterateDown(config, PPSUB_FILES_INV)) {
             psError(PPSUB_ERR_IO, false, "Unable to set up inverse files.");
-            return false;
+            success = false;
+            goto ESCAPE;
         }
 
         if (data->inverse && !ppSubDefineOutput("PPSUB.INVERSE", config)) {
             psError(psErrorCodeLast(), false, "Unable to define inverse.");
-            return false;
+            success = false;
+            goto ESCAPE;
         }
 
         if (!ppSubReadoutInverse(config)) {
             psError(psErrorCodeLast(), false, "Unable to invert images.");
-            return false;
+            success = false;
+            goto ESCAPE;
         }
 
@@ -264,15 +292,18 @@
         if (!ppSubFilesIterateUp(config, PPSUB_FILES_SUB)) {
             psError(PPSUB_ERR_IO, false, "Unable to close subtraction files.");
-            return false;
+            success = false;
+            goto ESCAPE;
         }
 
         if (!ppSubFilesIterateDown(config, PPSUB_FILES_PHOT_INV)) {
             psError(PPSUB_ERR_IO, false, "Unable to set up inverse files.");
-            return false;
+            success = false;
+            goto ESCAPE;
         }
 
         if (!data->quality && !ppSubReadoutPhotometry("PPSUB.INVERSE", data)) {
             psError(psErrorCodeLast(), false, "Unable to perform photometry.");
-            return false;
+            success = false;
+            goto ESCAPE;
         }
 
@@ -280,5 +311,6 @@
         if (!ppSubFilesIterateUp(config, PPSUB_FILES_INV | PPSUB_FILES_PHOT_INV)) {
             psError(PPSUB_ERR_IO, false, "Unable to close subtraction files.");
-            return false;
+            success = false;
+            goto ESCAPE;
         }
     } else {
@@ -287,12 +319,14 @@
         if (!ppSubFilesIterateUp(config, PPSUB_FILES_SUB)) {
             psError(PPSUB_ERR_IO, false, "Unable to close subtraction files.");
-            return false;
-        }
-    }
-
+            success = false;
+            goto ESCAPE;
+        }
+    }
+
+ESCAPE:
     pmFPAfileDropInternal(config->files, "PSPHOT.BACKGND");
     pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL");
     pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL.STDEV");
 
-    return true;
+    return success;
 }
