Index: trunk/ppImage/src/ppImageReplaceBackground.c
===================================================================
--- trunk/ppImage/src/ppImageReplaceBackground.c	(revision 20772)
+++ trunk/ppImage/src/ppImageReplaceBackground.c	(revision 20863)
@@ -75,5 +75,5 @@
     pmFPAfile *modelFile = psMetadataLookupPtr(&status, config->files, "PSPHOT.BACKMDL"); // Background model
     if (modelFile) {
-	modelRO = pmFPAviewThisReadout(&roView, modelFile->fpa); // Background model
+        modelRO = pmFPAviewThisReadout(&roView, modelFile->fpa); // Background model
     }
 
@@ -84,17 +84,17 @@
             return false;
         }
-	// the model file should now at least be defined
-	modelFile = psMetadataLookupPtr(&status, config->files, "PSPHOT.BACKMDL"); // Background model
-	if (!modelFile) {
+        // the model file should now at least be defined
+        modelFile = psMetadataLookupPtr(&status, config->files, "PSPHOT.BACKMDL"); // Background model
+        if (!modelFile) {
             psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to define background model I/O file");
             return false;
         }
-	// now grab the readout from the correct location:
+        // now grab the readout from the correct location:
         if (modelFile->mode == PM_FPA_MODE_INTERNAL) {
-	    modelRO = modelFile->readout;
-	} else {
-	    modelRO = pmFPAviewThisReadout(&roView, modelFile->fpa);
-	}        
-	if (!modelRO) {
+            modelRO = modelFile->readout;
+        } else {
+            modelRO = pmFPAviewThisReadout(&roView, modelFile->fpa);
+        }
+        if (!modelRO) {
             psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find background model");
             return false;
@@ -103,6 +103,6 @@
     psImageBinning *binning = psMetadataLookupPtr(&status, psphotRecipe, "PSPHOT.BACKGROUND.BINNING"); // Binning for model
     if (!binning) {
-	psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find background binning");
-	return false;
+        psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find background binning");
+        return false;
     }
 
@@ -143,14 +143,10 @@
     for (int y = 0; y < numRows; y++) {
         for (int x = 0; x < numCols; x++) {
-            if (mask && mask->data.PS_TYPE_MASK_DATA[y][x] & maskVal) {
-                image->data.F32[y][x] = 0.0;
+            float value = backData[y][x];
+            if (!isfinite(value)) {
+                image->data.F32[y][x] = NAN;
+                mask->data.PS_TYPE_MASK_DATA[y][x] |= options->badMask;
             } else {
-                float value = backData[y][x];
-                if (!isfinite(value)) {
-                    image->data.F32[y][x] = NAN;
-                    mask->data.PS_TYPE_MASK_DATA[y][x] |= options->badMask;
-                } else {
-                    image->data.F32[y][x] -= value;
-                }
+                image->data.F32[y][x] -= value;
             }
         }
@@ -175,7 +171,7 @@
     }
 # endif
-    
+
     // XXX should these really be here?? (probably not...)
-    // pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL"); 
+    // pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL");
     // pmFPAfileDropInternal(config->files, "PSPHOT.BACKMDL.STDEV");
 
