Index: trunk/ppMerge/src/ppMergeCombine.c
===================================================================
--- trunk/ppMerge/src/ppMergeCombine.c	(revision 13769)
+++ trunk/ppMerge/src/ppMergeCombine.c	(revision 13873)
@@ -83,4 +83,5 @@
 bool ppMergeCombine(psImage *scales,    // Scales for each cell of each integration, or NULL
                     psImage *zeros,     // Zeros for each cell of each integration, or NULL
+                    psArray *shutters, // Shutter correction data for each cell, or NULL
                     ppMergeData *data,  // Data
                     ppMergeOptions *options, // Options
@@ -100,4 +101,6 @@
                       zeros->numCols == data->numCells &&
                       zeros->numRows == filenames->n));
+    assert(!options->shutter || shutters);
+    assert(!shutters || (shutters->n == data->numCells));
 
     // Iterate over the FPA
@@ -143,4 +146,9 @@
             }
 
+            float shutterRef;           // Reference shutter correction
+            if (options->shutter) {
+                shutterRef = pmShutterCorrectionReference(shutters->data[cellNum]);
+            }
+
             do {
                 numRead = 0;
@@ -162,11 +170,11 @@
 
                     // Only reading and writing the first readout in each cell (plane 0)
-		    bool readOK;
+                    bool readOK;
                     if (pmReadoutReadNext(&readOK, stack->data[i], fits, 0, options->rows)) {
-			if (!readOK) {
-			    psError(PS_ERR_IO, false, "Failed to read concepts for cell.\n");
-			    psErrorStackPrint(stderr, "trouble reading data!\n");
-			    exit (1);
-			}
+                        if (!readOK) {
+                            psError(PS_ERR_IO, false, "Failed to read concepts for cell.\n");
+                            psErrorStackPrint(stderr, "trouble reading data!\n");
+                            exit (1);
+                        }
                         // If we're creating a bias or a dark, we don't want to generate a mask
                         if ((options->zero || options->scale || options->shutter || options->mask) &&
@@ -198,9 +206,7 @@
 
                     if (options->shutter) {
-                        pmShutterCorrectionMeasure(readout, stack, options->shutterSize,
-                                                   options->mean, options->stdev,
-                                                   options->shutterIter,
-                                                   options->shutterRej,
-                                                   options->combine->maskVal);
+                        pmShutterCorrectionGenerate(readout, NULL, stack, shutterRef, shutters->data[cellNum],
+                                                    options->shutterIter, options->shutterRej,
+                                                    options->combine->maskVal);
                     } else {
                         pmReadoutCombine(readout, stack, cellZeros, cellScales, options->combine);
@@ -271,16 +277,12 @@
             // Statistics on the merged cell
             if (data->statsFile) {
-		if (!data->stats) {
-		    data->stats = psMetadataAlloc();
-		}
-                if (!ppStats(data->stats, 
-			     data->out, 
-			     view, 
-			     options->combine->maskVal,
-			     config)) {
+                if (!data->stats) {
+                    data->stats = psMetadataAlloc();
+                }
+                if (!ppStats(data->stats, data->out, view, options->combine->maskVal, config)) {
                     psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to generate stats for image.\n");
-		    return false;
-		}
-	    }
+                    return false;
+                }
+            }
 
             // We threw away the bias sections --- record this
