Index: /trunk/ppSub/src/ppSubReadout.c
===================================================================
--- /trunk/ppSub/src/ppSubReadout.c	(revision 14294)
+++ /trunk/ppSub/src/ppSubReadout.c	(revision 14295)
@@ -43,10 +43,18 @@
     int numCols = input->numCols, numRows = input->numRows; // Image dimensions
     if (!inRO->mask) {
-        inRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
-        psImageInit(inRO->mask, 0);
+        if (psMetadataLookupBool(NULL, config->arguments, "MASK.GENERATE")) {
+            pmReadoutSetMask(inRO, pmConfigMask("SAT", config), pmConfigMask("BAD", config));
+        } else {
+            inRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
+            psImageInit(inRO->mask, 0);
+        }
     }
     if (!refRO->mask) {
-        refRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
-        psImageInit(refRO->mask, 0);
+        if (psMetadataLookupBool(NULL, config->arguments, "MASK.GENERATE")) {
+            pmReadoutSetMask(refRO, pmConfigMask("SAT", config), pmConfigMask("BAD", config));
+        } else {
+            refRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_MASK);
+            psImageInit(refRO->mask, 0);
+        }
     }
 
@@ -104,4 +112,12 @@
     }
 
+    if (numRejected > 0) {
+        solution = pmSubtractionSolveEquation(solution, stamps);
+        if (!solution) {
+            psError(PS_ERR_UNKNOWN, false, "Unable to calculate least-squares equation.");
+            goto ERROR;
+        }
+    }
+
     psImage *convImage = NULL, *convWeight = NULL, *convMask = NULL; // Convolved images
     if (!pmSubtractionConvolve(&convImage, &convWeight, &convMask, refRO->image, refRO->weight, subMask,
@@ -130,4 +146,12 @@
     outCell->data_exists = true;
     outCell->parent->data_exists = true;
+
+    for (int y = 0; y < outRO->image->numRows; y++) {
+        for (int x = 0; x < outRO->image->numCols; x++) {
+            if (isnan(outRO->image->data.F32[y][x]) && !(outRO->mask->data.U8[y][x] & maskBlank)) {
+                printf("%d %d --> %d\n", x, y, outRO->mask->data.U8[y][x]);
+            }
+        }
+    }
 
     if (!pmFPACopyConcepts(outCell->parent->parent, inRO->parent->parent->parent)) {
