Index: branches/tap_branches/pswarp/src/pswarpParseCamera.c
===================================================================
--- branches/tap_branches/pswarp/src/pswarpParseCamera.c	(revision 25900)
+++ branches/tap_branches/pswarp/src/pswarpParseCamera.c	(revision 27838)
@@ -23,20 +23,21 @@
     bool status;
 
-    // look for the file on the RUN metadata
-    pmFPAfile *file = pmFPAfileDefineFromRun(&status, bind, config, filerule); // File to return
+    pmFPAfile *file = NULL;
+    // look for the file on the argument list
+    if (bind) {
+        file = pmFPAfileBindFromArgs(&status, bind, config, filerule, argname);
+    } else {
+        file = pmFPAfileDefineFromArgs(&status, config, filerule, argname);
+    }
     if (!status) {
-        psError(PSWARP_ERR_CONFIG, false, "Failed to load file definition for %s", filerule);
-        return NULL;
+        psError(psErrorCodeLast(), false, "Failed to load file definition for %s", filerule);
+        return false;
     }
     if (!file) {
-        // look for the file on the argument list
-        if (bind) {
-            file = pmFPAfileBindFromArgs(&status, bind, config, filerule, argname);
-        } else {
-            file = pmFPAfileDefineFromArgs(&status, config, filerule, argname);
-        }
+        // look for the file on the RUN metadata
+        file = pmFPAfileDefineFromRun(&status, bind, config, filerule); // File to return
         if (!status) {
-            psError(PSWARP_ERR_CONFIG, false, "Failed to load file definition for %s", filerule);
-            return false;
+            psError(psErrorCodeLast(), false, "Failed to load file definition for %s", filerule);
+            return NULL;
         }
     }
@@ -64,5 +65,5 @@
     pmFPAfile *input = defineInputFile(config, NULL, "PSWARP.INPUT", "INPUT", PM_FPA_FILE_IMAGE);
     if (!input) {
-        psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.INPUT");
+        psError(psErrorCodeLast(), false, "Failed to build FPA from PSWARP.INPUT");
         return false;
     }
@@ -88,5 +89,5 @@
     bool status = pswarpDefineSkycell(&skycell, &skyConfig, config, "PSWARP.SKYCELL", "SKYCELL");
     if (!status) {
-        psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.SKYCELL");
+        psError(psErrorCodeLast(), false, "Failed to build FPA from PSWARP.SKYCELL");
         return false;
     }
@@ -96,5 +97,5 @@
     pmFPAfile *output = pmFPAfileDefineSkycell(config, NULL, "PSWARP.OUTPUT");
     if (!output) {
-        psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.OUTPUT");
+        psError(psErrorCodeLast(), false, "Failed to build FPA from PSWARP.OUTPUT");
         return false;
     }
@@ -103,5 +104,5 @@
     pmFPAfile *outMask = pmFPAfileDefineSkycell(config, output->fpa, "PSWARP.OUTPUT.MASK");
     if (!outMask) {
-        psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.OUTPUT.MASK");
+        psError(psErrorCodeLast(), false, "Failed to build FPA from PSWARP.OUTPUT.MASK");
         return false;
     }
@@ -111,5 +112,5 @@
         pmFPAfile *outVariance = pmFPAfileDefineSkycell(config, output->fpa, "PSWARP.OUTPUT.VARIANCE");
         if (!outVariance) {
-            psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.OUTPUT.VARIANCE");
+            psError(psErrorCodeLast(), false, "Failed to build FPA from PSWARP.OUTPUT.VARIANCE");
             return false;
         }
@@ -120,5 +121,5 @@
         pmFPAfile *outSources = pmFPAfileDefineSkycell(config, output->fpa, "PSWARP.OUTPUT.SOURCES");
         if (!outSources) {
-            psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.OUTPUT.SOURCES");
+            psError(psErrorCodeLast(), false, "Failed to build FPA from PSWARP.OUTPUT.SOURCES");
             return false;
         }
@@ -128,5 +129,5 @@
     psMetadata *recipe = psMetadataLookupPtr (&status, config->recipes, PSWARP_RECIPE);
     if (!recipe) {
-        psError(PSPHOT_ERR_CONFIG, false, "missing recipe %s", PSWARP_RECIPE);
+        psError(PSWARP_ERR_CONFIG, false, "missing recipe %s", PSWARP_RECIPE);
         return false;
     }
@@ -138,12 +139,14 @@
         pmFPAfile *psphotInput = pmFPAfileDefineSkycell(config, NULL, "PSPHOT.INPUT");
         if (!psphotInput) {
-            psError(PS_ERR_IO, false, _("Unable to generate output file from PSPHOT.INPUT"));
+            psError(psErrorCodeLast(), false, _("Unable to generate output file from PSPHOT.INPUT"));
             return false;
         }
         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");
         if (!psphotInSources) {
-            psError(PS_ERR_IO, false, _("Unable to generate output file from PSPHOT.INPUT.CMF"));
+            psError(psErrorCodeLast(), false, _("Unable to generate output file from PSPHOT.INPUT.CMF"));
             return false;
         }
@@ -152,5 +155,5 @@
         psMetadata *psphotRecipe = psMetadataLookupPtr(NULL, config->recipes, PSPHOT_RECIPE); // Recipe
         if (!psphotRecipe) {
-            psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to find %s recipe.", PSPHOT_RECIPE);
+            psError(PSWARP_ERR_CONFIG, false, "Unable to find %s recipe.", PSPHOT_RECIPE);
             return false;
         }
@@ -159,5 +162,5 @@
         // Define associated psphot input/output files
         if (!psphotDefineFiles(config, psphotInput)) {
-            psError(PSPHOT_ERR_CONFIG, false,
+            psError(PSWARP_ERR_CONFIG, false,
                     "Unable to define the additional input/output files for psphot");
             return false;
@@ -180,5 +183,5 @@
                 int chipNum = atoi(chips->data[i]);
                 if (! pmFPASelectChip(input->fpa, chipNum, false)) {
-                    psError(PSWARP_ERR_CONFIG, true, "Chip number %d doesn't exist in camera.\n", chipNum);
+                    psError(PSWARP_ERR_ARGUMENTS, true, "Chip number %d doesn't exist in camera.\n", chipNum);
                     return false;
                 }
