Index: trunk/pswarp/src/pswarpLoop.c
===================================================================
--- trunk/pswarp/src/pswarpLoop.c	(revision 25847)
+++ trunk/pswarp/src/pswarpLoop.c	(revision 26896)
@@ -162,19 +162,29 @@
         pmChip *chip;
         pmFPAview *view = pmFPAviewAlloc(0);
-        pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
+        if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
+            return false;
+        }
         while ((chip = pmFPAviewNextChip (view, input->fpa, 1)) != NULL) {
             psTrace ("pswarp", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
             if (!chip->process || !chip->file_exists) { continue; }
-            pmFPAfileIOChecks(config, view, PM_FPA_BEFORE);
+            if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
+                return false;
+            }
             pmCell *cell;
             while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
                 psTrace ("pswarp", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
                 if (!cell->process || !cell->file_exists) { continue; }
-                pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
-                pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
-            }
-            pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
-        }
-        pmFPAfileIOChecks (config, view, PM_FPA_AFTER);
+                if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE) ||
+                    !pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
+                    return false;
+                }
+            }
+            if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
+                return false;
+            }
+        }
+        if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) {
+            return false;
+        }
         psFree(view);
 
@@ -211,5 +221,7 @@
 
     // files associated with the science image
-    pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
+    if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
+        return false;
+    }
 
     pmChip *chip;
@@ -217,5 +229,7 @@
         psTrace ("pswarp", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
         if (!chip->process || !chip->file_exists) { continue; }
-        pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
+        if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
+            return false;
+        }
 
         // read WCS data from the corresponding header
@@ -242,5 +256,7 @@
             psTrace ("pswarp", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
             if (!cell->process || !cell->file_exists) { continue; }
-            pmFPAfileIOChecks (config, view, PM_FPA_BEFORE);
+            if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
+                return false;
+            }
 
             psListAdd(cells, PS_LIST_TAIL, cell);
@@ -249,26 +265,32 @@
             pmReadout *readout;
             while ((readout = pmFPAviewNextReadout(view, input->fpa, 1)) != NULL) {
-                pmFPAfileIOChecks(config, view, PM_FPA_BEFORE);
+                if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
+                    return false;
+                }
                 if (!readout->data_exists) {
                     continue;
                 }
 
-                // Copy the sources from the astrometry carrier to the input, so they can be accessed by
+                // Copy the detections from the astrometry carrier to the input, so they can be accessed by
                 // pswarpTransformReadout
                 pmReadout *astromRO = pmFPAviewThisReadout(view, astrom->fpa); // Readout for astrometry
-                psArray *sources = psMetadataLookupPtr(&mdok, astromRO->analysis,
-                                                       "PSPHOT.SOURCES"); // Sources from astrometry
-                if (sources) {
-                    psMetadataAddPtr(readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY,
-                                     "Sources from input astrometry", sources);
+                pmDetections *detections = psMetadataLookupPtr(&mdok, astromRO->analysis, "PSPHOT.DETECTIONS"); // Sources from astrometry
+                if (detections) {
+                    psMetadataAddPtr(readout->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_DATA_ARRAY, "Sources from input astrometry", detections);
                 }
 
                 pswarpTransformReadout(output, readout, config);
 
-                pmFPAfileIOChecks(config, view, PM_FPA_AFTER);
-            }
-            pmFPAfileIOChecks(config, view, PM_FPA_AFTER);
-        }
-        pmFPAfileIOChecks(config, view, PM_FPA_AFTER);
+                if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
+                    return false;
+                }
+            }
+            if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
+                return false;
+            }
+        }
+        if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
+            return false;
+        }
     }
 
@@ -370,5 +392,7 @@
     }
 
-    pmFPAfileIOChecks(config, view, PM_FPA_AFTER);
+    if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
+        return false;
+    }
 
     // Done with the detector side of things
@@ -478,5 +502,5 @@
         }
         fprintf(statsFile, "%s", statsMDC);
-        psFree((void*)statsMDC);
+        psFree(statsMDC);
         fclose(statsFile);
         pmConfigRunFilenameAddWrite(config, "STATS", statsName);
