Index: trunk/ppMerge/src/ppMergeScaleZero.c
===================================================================
--- trunk/ppMerge/src/ppMergeScaleZero.c	(revision 18756)
+++ trunk/ppMerge/src/ppMergeScaleZero.c	(revision 18930)
@@ -12,6 +12,4 @@
     psStatsOptions stdevStat = psMetadataLookupS32(NULL, config->arguments, "STDEV"); // Statistic for stdev
     int shutterSize = psMetadataLookupS32(NULL, config->arguments, "SHUTTER.SIZE"); // Size of shutter region
-
-    psMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask
 
     psVector *gains = NULL;             // Gains for each cell
@@ -82,4 +80,6 @@
                 pmReadout *readout = cell->readouts->data[0]; // Readout of interest
 
+                psMaskType maskVal = pmConfigMaskGet("MASK.VALUE", config); // Value to mask
+
                 switch (type) {
                   case PPMERGE_TYPE_FLAT:
@@ -88,9 +88,9 @@
                       float gain = psMetadataLookupF32(NULL, cell->concepts, "CELL.GAIN"); // Cell gain
                       if (!isfinite(gain)) {
-			// psError(PS_ERR_BAD_PARAMETER_VALUE, false,
-			// "CELL.GAIN for file %d chip %d cell %d is not set.",
-			// i, view->chip, view->cell);
-			// goto ERROR;
-			psWarning ("CELL.GAIN for file %d chip %d cell %d is NaN", i, view->chip, view->cell);
+                        // psError(PS_ERR_BAD_PARAMETER_VALUE, false,
+                        // "CELL.GAIN for file %d chip %d cell %d is not set.",
+                        // i, view->chip, view->cell);
+                        // goto ERROR;
+                        psWarning ("CELL.GAIN for file %d chip %d cell %d is NaN", i, view->chip, view->cell);
                       }
                       gains->data.F32[cellNum] = gain;
@@ -98,13 +98,13 @@
                       // Measure the background
                       if (!psImageBackground(stats, NULL, readout->image, readout->mask, maskVal, rng)) {
-			// psError(PS_ERR_UNKNOWN, false,
-			// "Unable to get statistics for file %d chip %d cell %d",
-			// i, view->chip, view->cell);
-			// goto ERROR;
-			psWarning ("Unable to get statistics for file %d chip %d cell %d", i, view->chip, view->cell);
-			background->data.F32[i][cellNum] = NAN;
+                        // psError(PS_ERR_UNKNOWN, false,
+                        // "Unable to get statistics for file %d chip %d cell %d",
+                        // i, view->chip, view->cell);
+                        // goto ERROR;
+                        psWarning ("Unable to get statistics for file %d chip %d cell %d", i, view->chip, view->cell);
+                        background->data.F32[i][cellNum] = NAN;
                       } else {
-			background->data.F32[i][cellNum] = psStatsGetValue(stats, meanStat);
-		      }
+                        background->data.F32[i][cellNum] = psStatsGetValue(stats, meanStat);
+                      }
                       break;
                   }
