Index: /trunk/ppImage/src/Makefile.am
===================================================================
--- /trunk/ppImage/src/Makefile.am	(revision 13527)
+++ /trunk/ppImage/src/Makefile.am	(revision 13528)
@@ -26,4 +26,5 @@
 	ppImageAstrom.c \
 	ppImageAddstar.c \
+	ppImageDefineFile.c \
 	ppImageVersion.c
 
@@ -47,4 +48,5 @@
 	ppImageAstrom.c \
 	ppImageAddstar.c \
+	ppImageDefineFile.c \
 	ppImageVersion.c
 
Index: /trunk/ppImage/src/ppFocusParseCamera.c
===================================================================
--- /trunk/ppImage/src/ppFocusParseCamera.c	(revision 13527)
+++ /trunk/ppImage/src/ppFocusParseCamera.c	(revision 13528)
@@ -25,30 +25,26 @@
     // not all input or output images are used in a given recipe
     if (options->doBias) {
-        bool status = false;
-        pmFPAfileDefineFromArgs  (&status, config, "PPIMAGE.BIAS", "BIAS");
-        pmFPAfileDefineFromConf  (&status, config, "PPIMAGE.BIAS");
-        pmFPAfileDefineFromDetDB (&status, config, "PPIMAGE.BIAS", input->fpa, PM_DETREND_TYPE_BIAS);
-        if (!status) psAbort("can't find a bias image source");
+	if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.BIAS", "BIAS", PM_FPA_FILE_IMAGE)) {
+	    psError (PS_ERR_IO, false, "Can't find a bias image source");
+	    return NULL;
+	}
     }
     if (options->doDark) {
-        bool status = false;
-        pmFPAfileDefineFromArgs  (&status, config, "PPIMAGE.DARK", "DARK");
-        pmFPAfileDefineFromConf  (&status, config, "PPIMAGE.DARK");
-        pmFPAfileDefineFromDetDB (&status, config, "PPIMAGE.DARK", input->fpa, PM_DETREND_TYPE_DARK);
-        if (!status) psAbort("can't find a dark image source");
+	if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.DARK", "DARK", PM_FPA_FILE_IMAGE)) {
+	    psError (PS_ERR_IO, false, "Can't find a dark image source");
+	    return NULL;
+	}
     }
     if (options->doMask) {
-        bool status = false;
-        pmFPAfileDefineFromArgs  (&status, config, "PPIMAGE.MASK", "MASK");
-        pmFPAfileDefineFromConf  (&status, config, "PPIMAGE.MASK");
-        pmFPAfileDefineFromDetDB (&status, config, "PPIMAGE.MASK", input->fpa, PM_DETREND_TYPE_MASK);
-        if (!status) psAbort("can't find a mask image source");
+	if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.MASK", "MASK", PM_FPA_FILE_MASK)) {
+	    psError (PS_ERR_IO, false, "Can't find a mask image source");
+	    return NULL;
+	}
     }
     if (options->doFlat) {
-        bool status = false;
-        pmFPAfileDefineFromArgs  (&status, config, "PPIMAGE.FLAT", "FLAT");
-        pmFPAfileDefineFromConf  (&status, config, "PPIMAGE.FLAT");
-        pmFPAfileDefineFromDetDB (&status, config, "PPIMAGE.FLAT", input->fpa, PM_DETREND_TYPE_FLAT);
-        if (!status) psAbort("can't find a flat image source");
+	if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.FLAT", "FLAT", PM_FPA_FILE_IMAGE)) {
+	    psError (PS_ERR_IO, false, "Can't find a shutter image source");
+	    return NULL;
+	}
     }
 
Index: /trunk/ppImage/src/ppImage.h
===================================================================
--- /trunk/ppImage/src/ppImage.h	(revision 13527)
+++ /trunk/ppImage/src/ppImage.h	(revision 13528)
@@ -61,3 +61,5 @@
 void ppFocusDropCamera (pmConfig *config);
 
+bool ppImageDefineFile (pmConfig *config, pmFPA *input, char *filerule, char *argname, pmFPAfileType type);
+
 #endif
Index: /trunk/ppImage/src/ppImageParseCamera.c
===================================================================
--- /trunk/ppImage/src/ppImageParseCamera.c	(revision 13527)
+++ /trunk/ppImage/src/ppImageParseCamera.c	(revision 13528)
@@ -22,5 +22,9 @@
     // if MASK or WEIGHT was supplied on command line, bind files to 'input'
     // the mask and weight will be mosaicked with the image
-    pmFPAfile *inputMask = pmFPAfileBindFromArgs(NULL, input, config, "PPIMAGE.INPUT.MASK", "INPUT.MASK");
+    pmFPAfile *inputMask = pmFPAfileBindFromArgs(&status, input, config, "PPIMAGE.INPUT.MASK", "INPUT.MASK");
+    if (!status) {
+	psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
+	return NULL;
+    }
     if (inputMask && inputMask->type != PM_FPA_FILE_MASK) {
         psError(PS_ERR_IO, true, "PPIMAGE.INPUT.MASK is not of type MASK");
@@ -28,5 +32,9 @@
     }
 
-    pmFPAfile *inputWeight = pmFPAfileBindFromArgs(NULL, input, config, "PPIMAGE.INPUT.WEIGHT", "INPUT.WEIGHT");
+    pmFPAfile *inputWeight = pmFPAfileBindFromArgs(&status, input, config, "PPIMAGE.INPUT.WEIGHT", "INPUT.WEIGHT");
+    if (!status) {
+	psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
+	return NULL;
+    }
     if (inputWeight && inputWeight->type != PM_FPA_FILE_WEIGHT) {
         psError(PS_ERR_IO, true, "PPIMAGE.INPUT.WEIGHT is not of type WEIGHT");
@@ -44,93 +52,38 @@
     // not all input or output images are used in a given recipe
     if (options->doBias) {
-        bool status = false;
-        pmFPAfileDefineFromArgs  (&status, config, "PPIMAGE.BIAS", "BIAS");
-        pmFPAfileDefineFromConf  (&status, config, "PPIMAGE.BIAS");
-        pmFPAfileDefineFromDetDB (&status, config, "PPIMAGE.BIAS", input->fpa, PM_DETREND_TYPE_BIAS);
-        pmFPAfile *bias = psMetadataLookupPtr(NULL, config->files, "PPIMAGE.BIAS");
-        if (!status || !bias) {
-            psError (PS_ERR_IO, false, "Can't find a bias image source");
-            psFree(options);
-            return NULL;
-        }
-        if (bias->type != PM_FPA_FILE_IMAGE) {
-            psError(PS_ERR_IO, true, "PPIMAGE.BIAS is not of type IMAGE");
-            psFree(options);
-            return NULL;
-        }
+	if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.BIAS", "BIAS", PM_FPA_FILE_IMAGE)) {
+	    psError (PS_ERR_IO, false, "Can't find a bias image source");
+	    psFree (options);
+	    return NULL;
+	}
     }
     if (options->doDark) {
-        bool status = false;
-        pmFPAfileDefineFromArgs  (&status, config, "PPIMAGE.DARK", "DARK");
-        pmFPAfileDefineFromConf  (&status, config, "PPIMAGE.DARK");
-        pmFPAfileDefineFromDetDB (&status, config, "PPIMAGE.DARK", input->fpa, PM_DETREND_TYPE_DARK);
-        pmFPAfile *dark = psMetadataLookupPtr(NULL, config->files, "PPIMAGE.DARK");
-        if (!status || !dark) {
-            psError (PS_ERR_IO, false, "Can't find a dark image source");
-            psFree(options);
-            return NULL;
-        }
-        if (dark->type != PM_FPA_FILE_IMAGE) {
-            psError(PS_ERR_IO, true, "PPIMAGE.DARK is not of type IMAGE");
-            psFree(options);
-            return NULL;
-        }
+	if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.DARK", "DARK", PM_FPA_FILE_IMAGE)) {
+	    psError (PS_ERR_IO, false, "Can't find a dark image source");
+	    psFree (options);
+	    return NULL;
+	}
     }
     if (options->doMask) {
-        bool status = false;
-        pmFPAfileDefineFromArgs  (&status, config, "PPIMAGE.MASK", "MASK");
-        pmFPAfileDefineFromConf  (&status, config, "PPIMAGE.MASK");
-        pmFPAfileDefineFromDetDB (&status, config, "PPIMAGE.MASK", input->fpa, PM_DETREND_TYPE_MASK);
-        pmFPAfile *mask = psMetadataLookupPtr(NULL, config->files, "PPIMAGE.MASK");
-        if (!status || !mask) {
-            psError (PS_ERR_IO, false, "Can't find a mask image source");
-            psFree(options);
-            return NULL;
-        }
-        if (mask->type != PM_FPA_FILE_MASK) {
-            psError(PS_ERR_IO, true, "PPIMAGE.MASK is not of type MASK");
-            psFree(options);
-            return NULL;
-        }
+	if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.MASK", "MASK", PM_FPA_FILE_MASK)) {
+	    psError (PS_ERR_IO, false, "Can't find a mask image source");
+	    psFree (options);
+	    return NULL;
+	}
     }
     if (options->doShutter) {
-        bool status = false;
-        pmFPAfileDefineFromArgs  (&status, config, "PPIMAGE.SHUTTER", "SHUTTER");
-        pmFPAfileDefineFromConf  (&status, config, "PPIMAGE.SHUTTER");
-        pmFPAfileDefineFromDetDB (&status, config, "PPIMAGE.SHUTTER", input->fpa, PM_DETREND_TYPE_SHUTTER);
-        pmFPAfile *shutter = psMetadataLookupPtr(NULL, config->files, "PPIMAGE.SHUTTER");
-        if (!status || !shutter) {
-            psError (PS_ERR_IO, false, "Can't find a shutter image source");
-            psFree(options);
-            return NULL;
-        }
-        if (shutter->type != PM_FPA_FILE_IMAGE) {
-            psError(PS_ERR_IO, true, "PPIMAGE.SHUTTER is not of type IMAGE");
-            psFree(options);
-            return NULL;
-        }
+	if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.SHUTTER", "SHUTTER", PM_FPA_FILE_IMAGE)) {
+	    psError (PS_ERR_IO, false, "Can't find a flat image source");
+	    psFree (options);
+	    return NULL;
+	}
     }
 
     if (options->doFlat) {
-        // if we fail to find the item in Args, we try again in Conf, then DetDB
-        // we need to handle the errors and catch serious errors, as opposed to
-        // data-not-found errors
-        bool status = false;
-        pmFPAfileDefineFromArgs  (&status, config, "PPIMAGE.FLAT", "FLAT");
-        psErrorClear();
-        pmFPAfileDefineFromConf  (&status, config, "PPIMAGE.FLAT");
-        psErrorClear();
-        pmFPAfileDefineFromDetDB (&status, config, "PPIMAGE.FLAT", input->fpa, PM_DETREND_TYPE_FLAT);
-        pmFPAfile *flat = psMetadataLookupPtr(NULL, config->files, "PPIMAGE.FLAT");
-        if (!status || !flat) {
-            psError (PS_ERR_IO, false, "Can't find a flat image source");
-            psFree(options);
-            return NULL;
-        }
-        if (flat->type != PM_FPA_FILE_IMAGE) {
-            psError(PS_ERR_IO, true, "PPIMAGE.FLAT is not of type IMAGE");
-            psFree(options);
-            return NULL;
-        }
+	if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.FLAT", "FLAT", PM_FPA_FILE_IMAGE)) {
+	    psError (PS_ERR_IO, false, "Can't find a shutter image source");
+	    psFree (options);
+	    return NULL;
+	}
     }
 
@@ -183,19 +136,8 @@
 skip_fringe:
     if (options->doFringe) {
-        bool status = false;
-        pmFPAfileDefineFromArgs  (&status, config, "PPIMAGE.FRINGE", "FRINGE");
-        pmFPAfileDefineFromConf  (&status, config, "PPIMAGE.FRINGE");
-        pmFPAfileDefineFromDetDB (&status, config, "PPIMAGE.FRINGE", input->fpa, PM_DETREND_TYPE_FRINGE_IMAGE);
-        pmFPAfile *fringe = psMetadataLookupPtr(NULL, config->files, "PPIMAGE.FRINGE");
-        if (!status || !fringe) {
-            psError (PS_ERR_IO, false, "Can't find a fringe image source");
-            psFree(options);
-            return NULL;
-        }
-        if (fringe->type != PM_FPA_FILE_FRINGE) {
-            psError(PS_ERR_IO, true, "PPIMAGE.FRINGE is not of type FRINGE");
-            psFree(options);
-            return NULL;
-        }
+	if (!ppImageDefineFile (config, input->fpa, "PPIMAGE.FRINGE", "FRINGE", PM_FPA_FILE_FRINGE)) {
+	    psError (PS_ERR_IO, false, "Can't find a fringe image source");
+	    return NULL;
+	}
     }
 
Index: /trunk/ppStack/src/ppStackCamera.c
===================================================================
--- /trunk/ppStack/src/ppStackCamera.c	(revision 13527)
+++ /trunk/ppStack/src/ppStackCamera.c	(revision 13528)
@@ -87,8 +87,7 @@
         psFree(maskFiles);
 
-        found = false;
-        pmFPAfile *maskFile = pmFPAfileBindFromArgs(&found, imageFile, config, "PPSTACK.INPUT.MASK",
-                                                    "MASK.FILENAMES");
-        if (!maskFile || !found) {
+	bool status;
+        pmFPAfile *maskFile = pmFPAfileBindFromArgs(&status, imageFile, config, "PPSTACK.INPUT.MASK", "MASK.FILENAMES");
+	if (!status) {
             psError(PS_ERR_UNKNOWN, false, "Unable to define file from mask %d (%s)", i, mask);
             return false;
Index: /trunk/ppSub/src/ppSubCamera.c
===================================================================
--- /trunk/ppSub/src/ppSubCamera.c	(revision 13527)
+++ /trunk/ppSub/src/ppSubCamera.c	(revision 13528)
@@ -26,5 +26,9 @@
 
     // Input mask
-    pmFPAfile *inputMask = pmFPAfileBindFromArgs(NULL, input, config, "PPSUB.INPUT.MASK", "INPUT.MASK");
+    pmFPAfile *inputMask = pmFPAfileBindFromArgs(&status, input, config, "PPSUB.INPUT.MASK", "INPUT.MASK");
+    if (!status) {
+	psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
+	return NULL;
+    }
     if (inputMask && inputMask->type != PM_FPA_FILE_MASK) {
         psError(PS_ERR_IO, true, "PPSUB.INPUT.MASK is not of type MASK");
@@ -33,5 +37,9 @@
 
     // Input weight map
-    pmFPAfile *inputWeight = pmFPAfileBindFromArgs(NULL, input, config, "PPSUB.INPUT.WEIGHT", "INPUT.WEIGHT");
+    pmFPAfile *inputWeight = pmFPAfileBindFromArgs(&status, input, config, "PPSUB.INPUT.WEIGHT", "INPUT.WEIGHT");
+    if (!status) {
+	psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
+	return NULL;
+    }
     if (inputWeight && inputWeight->type != PM_FPA_FILE_WEIGHT) {
         psError(PS_ERR_IO, true, "PPSUB.INPUT.WEIGHT is not of type WEIGHT");
@@ -52,5 +60,9 @@
 
     // Reference mask
-    pmFPAfile *refMask = pmFPAfileBindFromArgs(NULL, input, config, "PPSUB.REF.MASK", "REF.MASK");
+    pmFPAfile *refMask = pmFPAfileBindFromArgs(&status, input, config, "PPSUB.REF.MASK", "REF.MASK");
+    if (!status) {
+	psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
+	return NULL;
+    }
     if (refMask && refMask->type != PM_FPA_FILE_MASK) {
         psError(PS_ERR_IO, true, "PPSUB.REF.MASK is not of type MASK");
@@ -59,5 +71,9 @@
 
     // Reference weight map
-    pmFPAfile *refWeight = pmFPAfileBindFromArgs(NULL, input, config, "PPSUB.REF.WEIGHT", "REF.WEIGHT");
+    pmFPAfile *refWeight = pmFPAfileBindFromArgs(&status, input, config, "PPSUB.REF.WEIGHT", "REF.WEIGHT");
+    if (!status) {
+	psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
+	return NULL;
+    }
     if (refWeight && refWeight->type != PM_FPA_FILE_WEIGHT) {
         psError(PS_ERR_IO, true, "PPSUB.REF.WEIGHT is not of type WEIGHT");
Index: /trunk/psphot/src/psphotDefineFiles.c
===================================================================
--- /trunk/psphot/src/psphotDefineFiles.c	(revision 13527)
+++ /trunk/psphot/src/psphotDefineFiles.c	(revision 13528)
@@ -75,20 +75,22 @@
 
     // optionally save output plots
+    // allow specific plots only
     if (psMetadataLookupBool(NULL, recipe, "SAVE.PLOTS")) {
         if (!pmFPAfileDefineOutput (config, input->fpa, "SOURCE.PLOT.MOMENTS")) {
-            psTrace ("psphot", 3, "Cannot find a rule for SOURCE.PLOT.MOMENTS");
+            psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for SOURCE.PLOT.MOMENTS");
+            return false;
         }
         if (!pmFPAfileDefineOutput (config, input->fpa, "SOURCE.PLOT.PSFMODEL")) {
-            psTrace ("psphot", 3, "Cannot find a rule for SOURCE.PLOT.PSFMODEL");
+            psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for SOURCE.PLOT.PSFMODEL");
+            return false;
         }
         if (!pmFPAfileDefineOutput (config, input->fpa, "SOURCE.PLOT.APRESID")) {
-            psTrace ("psphot", 3, "Cannot find a rule for SOURCE.PLOT.APRESID");
+            psError(PSPHOT_ERR_CONFIG, false, "Cannot find a rule for SOURCE.PLOT.APRESID");
+            return false;
         }
     }
 
     if (psMetadataLookupPtr(NULL, config->arguments, "SRC")) {
-        status = false;
-        pmFPAfileDefineFromArgs (&status, config, "PSPHOT.INPUT.CMF", "SRC");
-        if (!status) {
+        if (!pmFPAfileDefineFromArgs (&status, config, "PSPHOT.INPUT.CMF", "SRC")) {
             psError(PSPHOT_ERR_CONFIG, false, "Failed to find/build PSPHOT.INPUT.CMF");
             return status;
@@ -97,7 +99,5 @@
 
     if (psMetadataLookupPtr(NULL, config->arguments, "PSPHOT.PSF")) {
-        status = false;
         pmFPAfileBindFromArgs(&status, input, config, "PSPHOT.PSF.LOAD", "PSPHOT.PSF");
-//        pmFPAfileDefineFromArgs (&status, config, "PSPHOT.PSF.LOAD", "PSPHOT.PSF");
         if (!status) {
             psError(PSPHOT_ERR_CONFIG, false, "Failed to find/build PSPHOT.PSF.LOAD");
@@ -111,13 +111,2 @@
     return true;
 }
-
-    // if we have requested PSPHOT.SRC, attempt to resolve it
-    // this is a list of input sources, stored in a psphot output format file
-    // XXX this was disabled after the switch to CHIP-mosaicked images.  It needs to be tested
-    // before it is added back into the code.
-# if (0)
-    // optionally load the PSF Model and/or fixed stars
-    // XXX add this back in later
-    // pmFPAfileBindFromArgs (NULL, input, config, "PSPHOT.PSF", "PSF");
-# endif
-
Index: /trunk/psphot/src/psphotParseCamera.c
===================================================================
--- /trunk/psphot/src/psphotParseCamera.c	(revision 13527)
+++ /trunk/psphot/src/psphotParseCamera.c	(revision 13528)
@@ -17,6 +17,15 @@
     // if MASK or WEIGHT was supplied on command line, bind files to 'load'
     // the mask and weight will be mosaicked with the image
-    pmFPAfileBindFromArgs (NULL, load, config, "PSPHOT.MASK",   "MASK");
-    pmFPAfileBindFromArgs (NULL, load, config, "PSPHOT.WEIGHT", "WEIGHT");
+    pmFPAfileBindFromArgs (&status, load, config, "PSPHOT.MASK",   "MASK");
+    if (!status) {
+	psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
+	return NULL;
+    }
+
+    pmFPAfileBindFromArgs (&status, load, config, "PSPHOT.WEIGHT", "WEIGHT");
+    if (!status) {
+	psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
+	return NULL;
+    }
 
     // the psphot analysis is performed on chips
Index: /trunk/pswarp/src/pswarpParseCamera.c
===================================================================
--- /trunk/pswarp/src/pswarpParseCamera.c	(revision 13527)
+++ /trunk/pswarp/src/pswarpParseCamera.c	(revision 13528)
@@ -10,5 +10,5 @@
     status = false;
     pmFPAfile *input = pmFPAfileDefineFromArgs (&status, config, "PSWARP.INPUT", "INPUT");
-    if (!input) {
+    if (!input || !status) {
         psError(PSWARP_ERR_CONFIG, false, "Failed to build FPA from PSWARP.INPUT");
         return false;
@@ -17,6 +17,10 @@
     // the input image(s) are required arguments; they define the camera
     status = false;
-    pmFPAfileDefineFromArgs (&status, config, "PSWARP.ASTROM", "ASTROM");
-    if (status) {
+    pmFPAfile *astrom = pmFPAfileDefineFromArgs (&status, config, "PSWARP.ASTROM", "ASTROM");
+    if (!status) {
+	psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
+	return NULL;
+    }
+    if (astrom) {
         psLogMsg ("pswarp", 3, "using supplied astrometry\n");
     } else {
@@ -25,10 +29,18 @@
 
     // the mask is not required - but must conform to input camera
-    pmFPAfile *inMask = pmFPAfileBindFromArgs(NULL, input, config, "PSWARP.MASK", "MASK");
+    pmFPAfile *inMask = pmFPAfileBindFromArgs(&status, input, config, "PSWARP.MASK", "MASK");
+    if (!status) {
+	psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
+	return NULL;
+    }
     if (!inMask) {
         psLogMsg ("pswarp", 3, "no mask supplied\n");
     }
 
-    pmFPAfile *inWeight = pmFPAfileBindFromArgs(NULL, input, config, "PSWARP.WEIGHT", "WEIGHT");
+    pmFPAfile *inWeight = pmFPAfileBindFromArgs(&status, input, config, "PSWARP.WEIGHT", "WEIGHT");
+    if (!status) {
+	psError (PS_ERR_UNKNOWN, false, "failed to load find definition");
+	return NULL;
+    }
     if (!inWeight) {
         psLogMsg ("pswarp", 3, "no weight supplied\n");
