Index: /trunk/pswarp/src/pswarpDefine.c
===================================================================
--- /trunk/pswarp/src/pswarpDefine.c	(revision 26895)
+++ /trunk/pswarp/src/pswarpDefine.c	(revision 26896)
@@ -77,12 +77,13 @@
         psFree(readout);                // Drop reference
 
-        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.XBIN");
-        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.YBIN");
-        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.XSIZE");
-        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.YSIZE");
-        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.XPARITY");
-        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.YPARITY");
-        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.X0");
-        psMetadataItemSupplement(target->concepts, source->concepts, "CELL.Y0");
+	bool status = false;
+        psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.XBIN");
+        psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.YBIN");
+        psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.XSIZE");
+        psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.YSIZE");
+        psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.XPARITY");
+        psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.YPARITY");
+        psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.X0");
+        psMetadataItemSupplement(&status, target->concepts, source->concepts, "CELL.Y0");
     }
 
Index: /trunk/pswarp/src/pswarpLoop.c
===================================================================
--- /trunk/pswarp/src/pswarpLoop.c	(revision 26895)
+++ /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);
Index: /trunk/pswarp/src/pswarpParseCamera.c
===================================================================
--- /trunk/pswarp/src/pswarpParseCamera.c	(revision 26895)
+++ /trunk/pswarp/src/pswarpParseCamera.c	(revision 26896)
@@ -143,4 +143,6 @@
         }
         psphotInput->src = psMemIncrRefCounter(output->fpa);
+	// specify the number of psphot input images
+	psMetadataAddS32 (config->arguments, PS_LIST_TAIL, "PSPHOT.INPUT.NUM", PS_META_REPLACE, "number of inputs", 1);
 
         pmFPAfile *psphotInSources = pmFPAfileDefineSkycell(config, output->fpa, "PSPHOT.INPUT.CMF");
Index: /trunk/pswarp/src/pswarpTransformReadout.c
===================================================================
--- /trunk/pswarp/src/pswarpTransformReadout.c	(revision 26895)
+++ /trunk/pswarp/src/pswarpTransformReadout.c	(revision 26896)
@@ -107,4 +107,7 @@
         psImageInit(output->mask, maskBad);
     }
+
+    // Ensure threading is off for the covariance calculation, since we are threading on a different level.
+    psImageCovarianceSetThreads(false);
 
     // create jobs and supply them to the threads
Index: /trunk/pswarp/src/pswarpTransformSources.c
===================================================================
--- /trunk/pswarp/src/pswarpTransformSources.c	(revision 26895)
+++ /trunk/pswarp/src/pswarpTransformSources.c	(revision 26896)
@@ -31,14 +31,20 @@
 
     // Transform sources
-    psArray *inSources = psMetadataLookupPtr(&mdok, input->analysis, "PSPHOT.SOURCES"); // Sources in source
+    pmDetections *inDetections = psMetadataLookupPtr(&mdok, input->analysis, "PSPHOT.DETECTIONS"); // Sources in source
+    if (!inDetections) return true;
+    psArray *inSources = inDetections->allSources;
     if (!inSources) return true;
 
     pswarpMapGrid *sourceGrid = pswarpMapGridFromImage(output, input, nGridX, nGridY); // Grid for sources
 
-    psArray *outSources = psMemIncrRefCounter(psMetadataLookupPtr(&mdok, output->analysis, "PSPHOT.SOURCES")); // Target sources
+    pmDetections *outDetections = psMemIncrRefCounter(psMetadataLookupPtr(&mdok, output->analysis, "PSPHOT.DETECTIONS")); // Target sources
+    if (!outDetections) {
+        outDetections = pmDetectionsAlloc();
+        psMetadataAddPtr(output->analysis, PS_LIST_TAIL, "PSPHOT.DETECTIONS", PS_DATA_ARRAY, "Warped sources", outDetections);
+    }
+    psArray *outSources = outDetections->allSources;
     if (!outSources) {
-        outSources = psArrayAllocEmpty(SOURCE_ARRAY_BUFFER);
-        psMetadataAddPtr(output->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY,
-                         "Warped sources", outSources);
+	outDetections->allSources = psArrayAllocEmpty(SOURCE_ARRAY_BUFFER);
+	outSources = outDetections->allSources;
     }
 
@@ -57,5 +63,5 @@
             psError(PS_ERR_UNKNOWN, false, "Unable to get grid coordinates for source at %f,%f\n",
                     xIn, yIn);
-            psFree(outSources);
+            psFree(outDetections);
             psFree(sourceGrid);
             return false;
@@ -72,5 +78,5 @@
             psError(PS_ERR_UNKNOWN, false, "Unable to transform coordinates for source at %f,%f\n",
                     xIn, yIn);
-            psFree(outSources);
+            psFree(outDetections);
             psFree(sourceGrid);
             return false;
@@ -142,5 +148,5 @@
     }
     psFree(sourceGrid);
-    psFree(outSources);             // Drop reference
+    psFree(outDetections);             // Drop reference
     return true;
 }
