Index: /trunk/ppImage/src/ppImageDetrendReadout.c
===================================================================
--- /trunk/ppImage/src/ppImageDetrendReadout.c	(revision 29925)
+++ /trunk/ppImage/src/ppImageDetrendReadout.c	(revision 29926)
@@ -62,5 +62,4 @@
     // Non-linearity correction
     if (options->doNonLin) {
-      //      linearity = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.LINEARITY");
       if (!ppImageDetrendNonLinear(input,detview,config)) {
 	psError(PS_ERR_UNKNOWN, false, "Unable to correct NonLinearity");
@@ -68,5 +67,4 @@
 	return(false);
       }
-      /*       ppImageDetrendNonLinear(detrend->input, input, options); */
     }
 
Index: /trunk/ppImage/src/ppImageOptions.c
===================================================================
--- /trunk/ppImage/src/ppImageOptions.c	(revision 29925)
+++ /trunk/ppImage/src/ppImageOptions.c	(revision 29926)
@@ -301,10 +301,30 @@
     options->checkCTE       = psMetadataLookupBool(NULL, recipe, "CHECK.CTE");
 
+    /* doMaskBuild : there are some cases where we require a mask, so we force doMaskBuild to be set even if the user specified 'FALSE'
+     *
+     * doPhotom : a mask is required because it is used to mark the locations of stars
+     *
+     * doNoiseMap : no reason this needs to trigger a mask?
+     * doBias : no reason this needs to trigger a mask?
+     * doOverscan : no reason this needs to trigger a mask?
+     * doDark : no reason this needs to trigger a mask?
+     * doShutter : no reason this needs to trigger a mask?
+     * doFlat : no reason this needs to trigger a mask?
+     */
+
     // even if not requested explicitly, if any of these are set, build an internal mask and variance:
-    if (options->doNoiseMap || options->doBias || options->doOverscan || options->doDark || options->doShutter || options->doFlat ||
-        options->doPhotom) {
-        options->doMaskBuild = true;
+    // XXX we used to automatically generate a mask in all of these cases.
+    // if (options->doNoiseMap || options->doBias || options->doOverscan || options->doDark || options->doShutter || options->doFlat || options->doPhotom) {
+    //     options->doMaskBuild = true;
+    //     options->doVarianceBuild = true;
+    // }
+
+    // photometry and noisemap both require a variance image
+    if (options->doNoiseMap || options->doPhotom) {
         options->doVarianceBuild = true;
-    } else if (options->doMask || options->doBG) {
+    } 
+
+    // photometry, mask, and background all require a mask image
+    if (options->doMask || options->doBG || options->doPhotom) {
         options->doMaskBuild = true;
     }
Index: /trunk/ppImage/src/ppImagePhotom.c
===================================================================
--- /trunk/ppImage/src/ppImagePhotom.c	(revision 29925)
+++ /trunk/ppImage/src/ppImagePhotom.c	(revision 29926)
@@ -11,7 +11,7 @@
     pmCell *cell;
     pmReadout *readout;
-    printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
+
     psphotInit();
-    printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
+
     // find or define a pmFPAfile PSPHOT.INPUT
     pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PSPHOT.INPUT");
@@ -20,10 +20,10 @@
         return false;
     }
-    printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
+
     // we make a new copy of the output chip to keep psphot from modifying the output image
     pmChip *oldChip = pmFPAviewThisChip (view, input->src);
     pmChip *newChip = pmFPAviewThisChip (view, input->fpa);
     pmChipCopy (newChip, oldChip);
-    printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
+
     // iterate over the cells and readout for this chip
     while ((cell = pmFPAviewNextCell (view, input->fpa, 1)) != NULL) {
@@ -34,7 +34,7 @@
         while ((readout = pmFPAviewNextReadout (view, input->fpa, 1)) != NULL) {
             if (! readout->data_exists) { continue; }
-	    printf("%x %s\n",psErrorCodeLast(),psErrorCodeString(psErrorCodeLast()));
+
             // run the actual photometry analysis
-            if (!psphotReadout (config, view)) {
+            if (!psphotReadout (config, view, "PSPHOT.INPUT")) {
                 // This is likely a data quality issue
                 // XXX Split into multiple cases using error codes?
@@ -60,10 +60,4 @@
     ppImageMemoryDump("photom");
 
-    // the PSPHOT.INPUT file is a temporary file used to carry PPIMAGE.CHIP to psphotReadout
-    // XXX not sure that this is needed...
-//    pmFPAfileActivate (config->files, false, "PSPHOT.INPUT");
-
     return true;
 }
-
-// XXX do we need to deactivate all files and activate the psphot ones explicitly?
Index: /trunk/ppImage/src/ppImageStatsOutput.c
===================================================================
--- /trunk/ppImage/src/ppImageStatsOutput.c	(revision 29925)
+++ /trunk/ppImage/src/ppImageStatsOutput.c	(revision 29926)
@@ -28,5 +28,14 @@
         return false;
     }
-    if (!psMetadataConfigWrite(stats, resolved)) {
+
+    // check for Metadata compression options:
+    char *compressMode;
+    bool status = false;
+    if (config->camera) {
+	// XXX use a different config variable for this output?
+	compressMode = psMetadataLookupStr(&status, config->camera, "METADATA.COMPRESSION");
+    }
+
+    if (!psMetadataConfigWrite(stats, resolved, compressMode)) {
         psError(psErrorCodeLast(), false, "Unable to serialize stats metadata.\n");
         psFree(resolved);
