Index: /branches/pap_branch_080320/ppMerge/src/ppMergeArguments.c
===================================================================
--- /branches/pap_branch_080320/ppMerge/src/ppMergeArguments.c	(revision 17156)
+++ /branches/pap_branch_080320/ppMerge/src/ppMergeArguments.c	(revision 17157)
@@ -244,6 +244,4 @@
     // Shutter construction parameters
     VALUE_ARG_RECIPE_INT("-shutter-size",  "SHUTTER.SIZE", S32, 0);
-    VALUE_ARG_RECIPE_INT("-shutter-iter",  "SHUTTER.ITER", S32, 0);
-    VALUE_ARG_RECIPE_FLOAT("-shutter-rej", "SHUTTER.REJECT", F32);
 
     // Mask construction parameters
Index: /branches/pap_branch_080320/ppMerge/src/ppMergeCamera.c
===================================================================
--- /branches/pap_branch_080320/ppMerge/src/ppMergeCamera.c	(revision 17156)
+++ /branches/pap_branch_080320/ppMerge/src/ppMergeCamera.c	(revision 17157)
@@ -5,4 +5,5 @@
 #include <stdio.h>
 #include <string.h>
+#include <assert.h>
 #include <pslib.h>
 #include <psmodules.h>
@@ -10,4 +11,43 @@
 #include "ppMerge.h"
 
+// Define an output file, with its own FPA
+bool outputFile(pmConfig *config,       // Configuration
+                const char *name,       // Name of output file
+                pmFPAfileType type,     // Type of file
+                const char *description, // Description of file
+                psMetadata *format,     // Camera format
+                pmFPAview *view         // View for PHU
+    )
+{
+    assert(config);
+    assert(name && strlen(name) > 0);
+    assert(view);
+
+    // Output image
+    pmFPA *fpa = pmFPAConstruct(config->camera); // FPA to contain the output
+    if (!fpa) {
+        psError(PS_ERR_UNEXPECTED_NULL, false, "Unable to construct an FPA from camera configuration.");
+        return false;
+    }
+
+    pmFPAfile *output = pmFPAfileDefineOutput(config, fpa, name);
+    psFree(fpa);                        // Drop reference
+    if (!output) {
+        psError(PS_ERR_IO, false, "Unable to generate output file from %s", name);
+        return false;
+    }
+    if (output->type != type) {
+        psError(PS_ERR_IO, true, "%s is not of type %s", name, pmFPAfileStringFromType(type));
+        return false;
+    }
+    output->save = true;
+
+    if (!pmFPAAddSourceFromView(fpa, description, view, format)) {
+        psError(PS_ERR_UNKNOWN, false, "Unable to generate output FPA.");
+        return false;
+    }
+
+    return true;
+}
 
 
@@ -191,4 +231,6 @@
                     psFree(cell->concepts);
                     cell->concepts = NULL;
+                    cell->data_exists = false;
+                    cell->file_exists = false;
                     culled++;
                 }
@@ -197,4 +239,6 @@
                 psFree(chip->concepts);
                 chip->concepts = NULL;
+                chip->data_exists = false;
+                chip->file_exists = false;
             }
         }
@@ -256,24 +300,21 @@
     }
 
-    pmFPAfile *output = pmFPAfileDefineOutput(config, fpa, outName);
-    psFree(fpa);                        // Drop reference
-    if (!output) {
-        psError(PS_ERR_IO, false, _("Unable to generate output file from %s"), outName);
+    if (!outputFile(config, outName, fileType, "Merged detrend", format, phuView)) {
         psFree(outName);
-        return false;
-    }
-    if (output->type != fileType) {
-        psError(PS_ERR_IO, true, "%s is not of type %s", outName, pmFPAfileStringFromType(fileType));
-        psFree(outName);
-        return false;
-    }
-    output->save = true;
+        psFree(phuView);
+        return false;
+    }
     psFree(outName);
 
-    if (!pmFPAAddSourceFromView(fpa, "Merged detrend", phuView, format)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to generate output FPA.");
-        psFree(fpa);
-        return false;
-    }
+    if (!outputFile(config, "PPMERGE.OUTPUT.SIGMA", fileType, "Merge sigma", format, phuView)) {
+        psFree(phuView);
+        return false;
+    }
+
+    if (!outputFile(config, "PPMERGE.OUTPUT.COUNT", fileType, "Merged count", format, phuView)) {
+        psFree(phuView);
+        return false;
+    }
+
     psFree(phuView);
 
Index: /branches/pap_branch_080320/ppMerge/src/ppMergeFiles.c
===================================================================
--- /branches/pap_branch_080320/ppMerge/src/ppMergeFiles.c	(revision 17156)
+++ /branches/pap_branch_080320/ppMerge/src/ppMergeFiles.c	(revision 17157)
@@ -11,8 +11,10 @@
 
 const char *allFiles[] = { "PPMERGE.INPUT", "PPMERGE.INPUT.MASK", "PPMERGE.INPUT.WEIGHT",
-                           "PPMERGE.OUTPUT", NULL };      // All files
+                           "PPMERGE.OUTPUT", "PPMERGE.OUTPUT.COUNT", "PPMERGE.OUTPUT.SIGMA",
+                           NULL };      // All files
 const char *inputFiles[] = { "PPMERGE.INPUT", "PPMERGE.INPUT.MASK", "PPMERGE.INPUT.WEIGHT",
                              NULL };    // Input files
-const char *outputFiles[] = { "PPMERGE.OUTPUT", NULL };   // Output files
+const char *outputFiles[] = { "PPMERGE.OUTPUT", "PPMERGE.OUTPUT.COUNT", "PPMERGE.OUTPUT.SIGMA",
+                              NULL };   // Output files
 
 // Select file list based on enum
Index: /branches/pap_branch_080320/ppMerge/src/ppMergeLoop.c
===================================================================
--- /branches/pap_branch_080320/ppMerge/src/ppMergeLoop.c	(revision 17156)
+++ /branches/pap_branch_080320/ppMerge/src/ppMergeLoop.c	(revision 17157)
@@ -49,8 +49,4 @@
     int fringeSmoothY = psMetadataLookupS32(NULL, arguments, "FRINGE.YSMOOTH"); // Smoothing regions in y
 
-    // Shutter parameters
-    int shutterIter = psMetadataLookupS32(NULL, arguments, "SHUTTER.ITER"); // Number of shutter iterations
-    float shutterRej = psMetadataLookupF32(NULL, arguments, "SHUTTER.REJ"); // Rejection limit for shutter
-
     pmCombineParams *combination = pmCombineParamsAlloc(combineStat); // Combination parameters
     combination->maskVal = maskVal;
@@ -152,83 +148,95 @@
             }
 
-            if (type == PPMERGE_TYPE_MASK) {
-                psAbort("Can't do masks yet.");
-#if 0
-                ppMergeMask(readouts, config);
-#endif
-            } else {
-                float shutterRef = NAN;     // Reference shutter correction
-                if (type == PPMERGE_TYPE_SHUTTER) {
-                    shutterRef = pmShutterCorrectionReference(shutters->data[cellNum]);
-                }
-
-                // Read convolutions by chunks
-                bool more = true;               // More to read?
-                for (int numChunk = 0; more; numChunk++) {
-                    psTrace("ppStack", 2, "Initial stack of chunk %d....\n", numChunk);
-                    for (int i = 0; i < numFiles; i++) {
-                        pmReadout *inRO = readouts->data[i]; // Input readout
-
-                        // Read a chunk from a file
-                        #define READ_CHUNK(NAME,TYPE) { \
-                            pmFPAfile *file = pmFPAfileSelectSingle(config->files, NAME, i); \
-                            if (!pmReadoutReadChunk##TYPE(inRO, file->fits, 0, rows, 0)) { \
-                                psError(PS_ERR_IO, false, "Unable to read chunk %d for file %s %d", \
-                                        numChunk, NAME, i); \
-                                psFree(readouts); \
-                                psFree(outRO); \
-                                psFree(view); \
-                                return false; \
-                            } \
-                        }
-
-                        READ_CHUNK("PPMERGE.INPUT", /* Blank */);
-                        if (haveMasks) {
-                            READ_CHUNK("PPMERGE.INPUT.MASK", Mask);
-                        }
-                        if (haveWeights) {
-                            READ_CHUNK("PPMERGE.INPUT.WEIGHT", Weight);
-                        }
-                    }
-
-                    switch (type) {
-                      case PPMERGE_TYPE_SHUTTER:
-                        pmShutterCorrectionGenerate(outRO, NULL, readouts, shutterRef,
-                                                    shutters->data[cellNum], shutterIter, shutterRej,
-                                                    maskVal);
-                        break;
-                      case PPMERGE_TYPE_DARK:
-                        pmDarkCombine(outCell, readouts, darkOrdinates, darkNorm, iter, rej, maskVal);
-                        break;
-                      case PPMERGE_TYPE_BIAS:
-                      case PPMERGE_TYPE_FLAT:
-                      case PPMERGE_TYPE_FRINGE:
-                        pmReadoutCombine(outRO, readouts, zeros, scales, combination);
-                        break;
-                      default:
-                        psAbort("Should never get here.");
-                    }
-
-
-                    for (int i = 0; i < numFiles && more; i++) {
-                        pmReadout *inRO = readouts->data[i];
-
-                        // Check to see if there's more chunks to read
-                        #define MORE_CHUNK(NAME,TYPE) { \
-                            pmFPAfile *file = pmFPAfileSelectSingle(config->files, NAME, i); \
-                            more &= pmReadoutMore##TYPE(inRO, file->fits, 0, rows); \
-                        }
-
-                        MORE_CHUNK("PPMERGE.INPUT", /* Blank */);
-                        if (haveMasks) {
-                            MORE_CHUNK("PPMERGE.INPUT.MASK", Mask);
-                        }
-                        if (haveWeights) {
-                            MORE_CHUNK("PPMERGE.INPUT.WEIGHT", Weight);
-                        }
+            float shutterRef = NAN;     // Reference shutter correction
+            if (type == PPMERGE_TYPE_SHUTTER) {
+                shutterRef = pmShutterCorrectionReference(shutters->data[cellNum]);
+            }
+
+            // Read convolutions by chunks
+            bool more = true;               // More to read?
+            for (int numChunk = 0; more; numChunk++) {
+                psTrace("ppStack", 2, "Initial stack of chunk %d....\n", numChunk);
+                for (int i = 0; i < numFiles; i++) {
+                    pmReadout *inRO = readouts->data[i]; // Input readout
+
+                    // Read a chunk from a file
+                    #define READ_CHUNK(NAME,TYPE) { \
+                        pmFPAfile *file = pmFPAfileSelectSingle(config->files, NAME, i); \
+                        if (!pmReadoutReadChunk##TYPE(inRO, file->fits, 0, rows, 0)) { \
+                            psError(PS_ERR_IO, false, "Unable to read chunk %d for file %s %d", \
+                                    numChunk, NAME, i); \
+                            psFree(readouts); \
+                            psFree(outRO); \
+                            psFree(view); \
+                            return false; \
+                        } \
+                    }
+
+                    READ_CHUNK("PPMERGE.INPUT", /* Blank */);
+                    if (haveMasks) {
+                        READ_CHUNK("PPMERGE.INPUT.MASK", Mask);
+                    }
+                    if (haveWeights) {
+                        READ_CHUNK("PPMERGE.INPUT.WEIGHT", Weight);
+                    }
+                }
+
+                switch (type) {
+                  case PPMERGE_TYPE_SHUTTER:
+                    pmShutterCorrectionGenerate(outRO, NULL, readouts, shutterRef,
+                                                shutters->data[cellNum], iter, rej,
+                                                maskVal);
+                    break;
+                  case PPMERGE_TYPE_DARK:
+                    pmDarkCombine(outCell, readouts, darkOrdinates, darkNorm, iter, rej, maskVal);
+                    break;
+                  case PPMERGE_TYPE_BIAS:
+                  case PPMERGE_TYPE_FLAT:
+                  case PPMERGE_TYPE_FRINGE:
+                    pmReadoutCombine(outRO, readouts, zeros, scales, combination);
+                    break;
+                  default:
+                    psAbort("Should never get here.");
+                }
+
+
+                for (int i = 0; i < numFiles && more; i++) {
+                    pmReadout *inRO = readouts->data[i];
+
+                    // Check to see if there's more chunks to read
+                    #define MORE_CHUNK(NAME,TYPE) { \
+                        pmFPAfile *file = pmFPAfileSelectSingle(config->files, NAME, i); \
+                        more &= pmReadoutMore##TYPE(inRO, file->fits, 0, rows); \
+                    }
+
+                    MORE_CHUNK("PPMERGE.INPUT", /* Blank */);
+                    if (haveMasks) {
+                        MORE_CHUNK("PPMERGE.INPUT.MASK", Mask);
+                    }
+                    if (haveWeights) {
+                        MORE_CHUNK("PPMERGE.INPUT.WEIGHT", Weight);
                     }
                 }
             }
             psFree(readouts);
+
+            // Plug supplementary images into their own FPAs
+            {
+                pmCell *countsCell = pmFPAfileThisCell(config->files, view, "PPMERGE.OUTPUT.COUNT");
+                pmReadout *countsRO = pmReadoutAlloc(countsCell); // Readout with count of inputs per pixel
+                psImage *counts = psMetadataLookupPtr(NULL, outRO->analysis, PM_READOUT_STACK_ANALYSIS_COUNT);
+                countsRO->image = psImageCopy(countsRO->image, counts, PS_TYPE_F32);
+                psMetadataRemoveKey(outRO->analysis, PM_READOUT_STACK_ANALYSIS_COUNT);
+                countsRO->data_exists = countsCell->data_exists = countsCell->parent->data_exists = true;
+                psFree(countsRO);
+
+                pmCell *sigmaCell = pmFPAfileThisCell(config->files, view, "PPMERGE.OUTPUT.SIGMA");
+                pmReadout *sigmaRO = pmReadoutAlloc(sigmaCell); // Readout with stdev per pixel
+                psImage *sigma = psMetadataLookupPtr(NULL, outRO->analysis, PM_READOUT_STACK_ANALYSIS_SIGMA);
+                sigmaRO->image = psImageCopy(sigmaRO->image, sigma, PS_TYPE_F32);
+                psMetadataRemoveKey(outRO->analysis, PM_READOUT_STACK_ANALYSIS_SIGMA);
+                sigmaRO->data_exists = sigmaCell->data_exists = sigmaCell->parent->data_exists = true;
+                psFree(sigmaRO);
+            }
 
             // Measure the fringes for this cell
Index: /branches/pap_branch_080320/ppMerge/src/ppMergeMask.c
===================================================================
--- /branches/pap_branch_080320/ppMerge/src/ppMergeMask.c	(revision 17156)
+++ /branches/pap_branch_080320/ppMerge/src/ppMergeMask.c	(revision 17157)
@@ -44,5 +44,4 @@
 
     // For each input file, get the statistics, which can be calculated at the chip or cell levels
-    psArray *suspects = psArrayAlloc(outChip->cells->n); // Images with suspected pixels
     psVector *values = psVectorAlloc(sample, PS_TYPE_F32); // Pixel values for statistics
     pmFPAview *inView = pmFPAviewAlloc(0); // View for input
@@ -100,12 +99,12 @@
             }
 
-            psImage *outMask = NULL;    // Output mask image (for iterative generation of mask)
             pmCell *outCell = pmFPAfileThisCell(config->files, inView, "PPMERGE.OUTPUT.MASK"); // Output cell
+            pmReadout *outRO = NULL;    // Output readout
             if (outCell->readouts && outCell->readouts->n == 1) {
-                pmReadout *outRO = outCell->readouts->data[0]; // Output readout
-                if (outRO) {
-                    outMask = outRO->mask;
-                }
-            }
+                outRO = psMemIncrRefCounter(outCell->readouts->data[0]);
+            } else {
+                outRO = pmReadoutAlloc(outCell);
+            }
+            psImage *outMask = outRO->mask;    // Output mask image (for iterative generation of mask)
 
             psImage *image = readout->image, *mask = readout->mask; // Image and mask
@@ -139,10 +138,11 @@
                 }
 
-                psMetadataAddF32(readout->analysis, PS_LIST_TAIL, PM_MASK_ANALYSIS_MEAN, PS_META_REPLACE,
-                                 "Mean value of readout", psStatsGetValue(statistics, meanStat));
-                psMetadataAddF32(readout->analysis, PS_LIST_TAIL, PM_MASK_ANALYSIS_STDEV, PS_META_REPLACE,
-                                 "Stdev value of readout", psStatsGetValue(statistics, stdevStat));
-                suspects->data[inView->cell] = pmMaskFlagSuspectPixels(suspects->data[inView->cell],
-                                                                       readout, maskSuspect, maskVal);
+                if (!pmMaskFlagSuspectPixels(outRO, readout, psStatsGetValue(statistics, meanStat),
+                                             psStatsGetValue(statistics, stdevStat), maskSuspect, maskVal)) {
+                    psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i);
+                    psFree(inView);
+                    psFree(readout);
+                    goto MERGE_MASK_ERROR;
+                }
                 pmCellFreeData(inCell);
 
@@ -154,4 +154,5 @@
             }
             psFree(readout);
+            psFree(outRO);
         }
 
@@ -172,10 +173,12 @@
                 pmReadout *readout = inCell->readouts->data[0]; // Readout of interest
 
-                psMetadataAddF32(readout->analysis, PS_LIST_TAIL, PM_MASK_ANALYSIS_MEAN, PS_META_REPLACE,
-                                 "Mean value of chip", psStatsGetValue(statistics, meanStat));
-                psMetadataAddF32(readout->analysis, PS_LIST_TAIL, PM_MASK_ANALYSIS_STDEV, PS_META_REPLACE,
-                                 "Stdev value of chip", psStatsGetValue(statistics, stdevStat));
-                suspects->data[inView->cell] = pmMaskFlagSuspectPixels(suspects->data[inView->cell],
-                                                                       readout, maskSuspect, maskVal);
+                inView->readout = 0;
+                pmReadout *outRO = pmFPAfileThisReadout(config->files, inView, "PPMERGE.OUTPUT.MASK");
+
+                if (!pmMaskFlagSuspectPixels(outRO, readout, psStatsGetValue(statistics, meanStat),
+                                             psStatsGetValue(statistics, stdevStat), maskSuspect, maskVal)) {
+                    psError(PS_ERR_UNKNOWN, false, "Unable to find suspect values in file %d", i);
+                    goto MERGE_MASK_ERROR;
+                }
                 pmCellFreeData(inCell);
 
@@ -210,21 +213,34 @@
         psTrace("ppMerge", 1, "Getting bad pixels for chip %d cell %d", outView->chip, outView->cell);
 
-        pmReadout *outRO = NULL;    // Output readout
-        if (outCell->readouts && outCell->readouts->n == 1) {
-            outRO = psMemIncrRefCounter(outCell->readouts->data[0]);
-        } else {
-            outRO = pmReadoutAlloc(outCell);
-        }
-
-        psImage *mask = pmMaskIdentifyBadPixels(suspects->data[outView->cell], maskVal, numFiles, maskBad,
-                                                maskMode);
-        psFree(suspects->data[outView->cell]);
-        suspects->data[outView->cell] = NULL;
+        assert(outCell->readouts && outCell->readouts->n == 1);
+        pmReadout *outRO = outCell->readouts->data[0]; // Output readout
+        if (!pmMaskIdentifyBadPixels(outRO, maskVal, maskBad, maskMode)) {
+            psError(PS_ERR_UNKNOWN, false, "Unable to mask bad pixels");
+            goto MERGE_MASK_ERROR;
+        }
+
+        // Supplementary outputs
+        {
+            // The counts image is fairly useless, but it preserves the model
+            pmCell *countsCell = pmFPAfileThisCell(config->files, view, "PPMERGE.OUTPUT.COUNT");
+            pmReadout *countsRO = pmReadoutAlloc(countsCell); // Readout with count of inputs per pixel
+            countsRO->image = psImageAlloc(outRO->image->numCols, outRO->image->numRows, PS_TYPE_F32);
+            psImageInit(countsRO->image, numFiles);
+            countsRO->data_exists = countsCell->data_exists = countsCell->parent->data_exists = true;
+            psFree(countsRO);
+
+            pmCell *sigmaCell = pmFPAfileThisCell(config->files, view, "PPMERGE.OUTPUT.SIGMA");
+            pmReadout *sigmaRO = pmReadoutAlloc(sigmaCell); // Readout with suspect image
+            psImage *suspect = psMetadataLookupPtr(NULL, outRO->analysis, PM_MASK_ANALYSIS_SUSPECT);
+            sigmaRO->image = psImageCopy(sigmaRO->image, suspect, PS_TYPE_F32);
+            psMetadataRemoveKey(outRO->analysis, PM_MASK_ANALYSIS_SUSPECT);
+            sigmaRO->data_exists = sigmaCell->data_exists = sigmaCell->parent->data_exists = true;
+            psFree(sigmaRO);
+        }
+
         if (maskGrowVal > 0) {
-            outRO->mask = psImageGrowMask(outRO->mask, mask, maskVal, maskGrow, maskGrowVal);
-            psFree(mask);
-        } else {
+            psImage *grown = psImageGrowMask(NULL, outRO->mask, maskVal, maskGrow, maskGrowVal); // Grown mask
             psFree(outRO->mask);
-            outRO->mask = mask;
+            outRO->mask = grown;
         }
 
@@ -278,10 +294,8 @@
     ppMergeFileActivate(config, PPMERGE_FILES_ALL, true);
 
-    psFree(suspects);
     return true;
 
 
 MERGE_MASK_ERROR:
-    psFree(suspects);
     psFree(statistics);
     psFree(values);
Index: /branches/pap_branch_080320/ppMerge/src/ppMergeScaleZero.c
===================================================================
--- /branches/pap_branch_080320/ppMerge/src/ppMergeScaleZero.c	(revision 17156)
+++ /branches/pap_branch_080320/ppMerge/src/ppMergeScaleZero.c	(revision 17157)
@@ -23,6 +23,4 @@
     psMaskType maskVal = psMetadataLookupU8(NULL, config->arguments, "MASKVAL"); // Value to mask
     int shutterSize = psMetadataLookupS32(NULL, config->arguments, "SHUTTER.SIZE"); // Size of shutter region
-    int sample = psMetadataLookupS32(NULL, config->arguments, "SAMPLE"); // Maximum size of sample
-    bool chipStats = false;             // Do statistics on full chip instead of cell?
 
     psVector *gains = NULL;             // Gains for each cell
@@ -47,5 +45,4 @@
         break;
       case PPMERGE_TYPE_MASK:
-        stats = psStatsAlloc(meanStat | stdevStat);
       default:
         break;
@@ -53,6 +50,4 @@
     psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS, 0); // Random number generator
     pmFPAview *view = NULL;             // View into FPA
-
-    psVector *values = psVectorAlloc(sample, PS_TYPE_F32); // Values for statistics
 
     for (int i = 0; i < numInputs; i++) {
@@ -74,6 +69,4 @@
                 goto ERROR;
             }
-
-            int valueIndex = 0;         // Index into values vector
 
             pmCell *cell;               // Cell of interest
@@ -138,38 +131,5 @@
                       break;
                   }
-                  case PPMERGE_TYPE_MASK: {
-                      psImage *image = readout->image, *mask = readout->mask; // Image and mask
-                      int numCols = readout->image->numCols, numRows = readout->image->numRows; // Image size
-                      int numPix = numCols * numRows; // Number of pixels
-                      int numCells = chipStats ? readout->parent->parent->cells->n : 1; // Number of cells
-                      int num = PS_MIN(numPix, sample / numCells); // Number of values to add
-                      if (!chipStats) {
-                          valueIndex = 0;
-                      }
-                      for (int i = 0; i < num; i++) {
-                          int pixel = numPix * psRandomUniform(rng);
-                          int x = pixel % numCols;
-                          int y = pixel / numCols;
-                          if ((mask && (mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal)) ||
-                              !isfinite(image->data.F32[y][x])) {
-                              continue;
-                          }
-
-                          values->data.F32[valueIndex++] = image->data.F32[y][x];
-                      }
-
-                      if (!chipStats) {
-                          if (!psVectorStats(stats, values, NULL, NULL, 0)) {
-                              psError(PS_ERR_UNKNOWN, false, "Unable to do statistics on readout.");
-                              goto ERROR;
-                          }
-
-                          psMetadataAddF32(cell->analysis, PS_LIST_TAIL, PM_MASK_ANALYSIS_MEAN, 0,
-                                           "Mean value of readout", psStatsGetValue(stats, meanStat));
-                          psMetadataAddF32(cell->analysis, PS_LIST_TAIL, PM_MASK_ANALYSIS_STDEV, 0,
-                                           "Stdev value of readout", psStatsGetValue(stats, stdevStat));
-                      }
-                      break;
-                  }
+                  case PPMERGE_TYPE_MASK:
                   default:
                     psAbort("Should never get here.");
@@ -178,27 +138,6 @@
                 cellNum++;
 
-                if ((type != PPMERGE_TYPE_MASK || !chipStats) &&
-                    !pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
+                if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
                     goto ERROR;
-                }
-            }
-
-            // Additional run through cells if we want chip-level statistics for masks
-            if (type == PPMERGE_TYPE_MASK && chipStats) {
-                if (!psVectorStats(stats, values, NULL, NULL, 0)) {
-                    psError(PS_ERR_UNKNOWN, false, "Unable to do statistics on chip.");
-                    goto ERROR;
-                }
-                while ((cell = pmFPAviewNextCell(view, fpa, 1))) {
-                    if (!cell->data_exists) {
-                        continue;
-                    }
-                    psMetadataAddF32(cell->analysis, PS_LIST_TAIL, PM_MASK_ANALYSIS_MEAN, 0,
-                                     "Mean value of chip", psStatsGetValue(stats, meanStat));
-                    psMetadataAddF32(cell->analysis, PS_LIST_TAIL, PM_MASK_ANALYSIS_STDEV, 0,
-                                     "Stdev value of chip", psStatsGetValue(stats, stdevStat));
-                    if (!pmFPAfileIOChecks(config, view, PM_FPA_AFTER)) {
-                        goto ERROR;
-                    }
                 }
             }
@@ -256,4 +195,5 @@
                            "Shutter data", shutters);
         break;
+      case PPMERGE_TYPE_MASK:
       default:
         psAbort("Should never get here.");
