Index: /trunk/psphot/src/psphotReadout.c
===================================================================
--- /trunk/psphot/src/psphotReadout.c	(revision 13303)
+++ /trunk/psphot/src/psphotReadout.c	(revision 13304)
@@ -24,5 +24,6 @@
 
     // generate mask & weight images if they don't already exit
-    if (!pmReadoutGenerateMaskWeight (readout, true)) {
+    if ((!readout->mask && !pmReadoutGenerateMask(readout)) ||
+        (!readout->weight && !pmReadoutGenerateWeight(readout, true))) {
         psError (PSPHOT_ERR_CONFIG, false, "trouble creating mask and/or weight");
         return false;
@@ -71,6 +72,6 @@
 
     if (!peaks) {
-	psLogMsg ("psphot", 3, "unable to find peaks in this image");
-	return psphotReadoutCleanup (config, readout, recipe, NULL, NULL);
+        psLogMsg ("psphot", 3, "unable to find peaks in this image");
+        return psphotReadoutCleanup (config, readout, recipe, NULL, NULL);
     }
 
@@ -91,12 +92,12 @@
     // mark blended peaks PS_SOURCE_BLEND
     if (!psphotBasicDeblend (sources, recipe)) {
-	psLogMsg ("psphot", 3, "failed on deblend analysis");
-	return psphotReadoutCleanup (config, readout, recipe, NULL, sources);
+        psLogMsg ("psphot", 3, "failed on deblend analysis");
+        return psphotReadoutCleanup (config, readout, recipe, NULL, sources);
     }
 
     // classify sources based on moments, brightness
     if (!psphotRoughClass (sources, recipe)) {
-	psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");
-	return psphotReadoutCleanup (config, readout, recipe, NULL, sources);
+        psLogMsg ("psphot", 3, "failed to find a valid PSF clump for image");
+        return psphotReadoutCleanup (config, readout, recipe, NULL, sources);
     }
     if (!strcasecmp (breakPt, "MOMENTS")) {
@@ -107,10 +108,10 @@
     pmPSF *psf = psphotLoadPSF (config, view, recipe);
     if (!psf) {
-	// use bright stellar objects to measure PSF
-	psf = psphotChoosePSF (readout, sources, recipe);
-	if (psf == NULL) {
-	    psLogMsg ("psphot", 3, "failure to construct a psf model");
-	    return psphotReadoutCleanup (config, readout, recipe, psf, sources);
-	}
+        // use bright stellar objects to measure PSF
+        psf = psphotChoosePSF (readout, sources, recipe);
+        if (psf == NULL) {
+            psLogMsg ("psphot", 3, "failure to construct a psf model");
+            return psphotReadoutCleanup (config, readout, recipe, psf, sources);
+        }
     }
     if (!strcasecmp (breakPt, "PSFMODEL")) {
@@ -121,8 +122,8 @@
     psphotLoadExtSources (config, view, sources);
 
-    // construct an initial model for each object 
+    // construct an initial model for each object
     psphotGuessModels (readout, sources, recipe, psf);
 
-    // XXX test output of models 
+    // XXX test output of models
     // psphotTestSourceOutput (readout, sources, recipe, psf);
 
@@ -205,5 +206,5 @@
 finish:
 
-    // plot positive sources 
+    // plot positive sources
     // psphotSourcePlots (readout, sources, recipe);
 
