Index: /trunk/ppImage/src/ppImageDetrendReadout.c
===================================================================
--- /trunk/ppImage/src/ppImageDetrendReadout.c	(revision 24077)
+++ /trunk/ppImage/src/ppImageDetrendReadout.c	(revision 24078)
@@ -17,6 +17,6 @@
     // Masking on the basis of pixel value needs to be done before anything else, so the values are pristine.
     if (options->doMaskBuild) {
-	psImageMaskType satMask = options->doMaskSat ? options->satMask : 0;
-	psImageMaskType lowMask = options->doMaskLow ? options->lowMask : 0;
+        psImageMaskType satMask = options->doMaskSat ? options->satMask : 0;
+        psImageMaskType lowMask = options->doMaskLow ? options->lowMask : 0;
         pmReadoutGenerateMask(input, satMask, lowMask);
     }
@@ -56,5 +56,5 @@
         if (!pmBiasSubtract(input, options->overscan, bias, oldDark, view)) {
             psError(PS_ERR_UNKNOWN, false, "Unable to subtract bias.");
-	    psFree(detview);
+            psFree(detview);
             return false;
         }
@@ -68,7 +68,7 @@
 
     if (options->doDark && dark) {
-        if (!pmDarkApply(input, dark, options->maskValue)) {
+        if (!pmDarkApply(input, dark, options->flatMask)) {
             psError(PS_ERR_UNKNOWN, false, "Unable to subtract dark.");
-	    psFree(detview);
+            psFree(detview);
             return false;
         }
@@ -79,5 +79,5 @@
                         options->remnanceSize, options->remnanceThresh)) {
             psError(PS_ERR_UNKNOWN, false, "Unable to mask remnance.");
-	    psFree(detview);
+            psFree(detview);
             return false;
         }
@@ -88,5 +88,5 @@
         pmReadout *shutter = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.SHUTTER");
         if (!pmShutterCorrectionApply(input, shutter, pmConfigMaskGet("FLAT", config))) {
-	    psFree(detview);
+            psFree(detview);
             return false;
         }
@@ -97,5 +97,5 @@
         pmReadout *flat = pmFPAfileThisReadout(config->files, detview, "PPIMAGE.FLAT");
         if (!pmFlatField(input, flat, options->flatMask)) {
-	    psFree(detview);
+            psFree(detview);
             return false;
         }
@@ -119,35 +119,35 @@
     psMetadata *normlist = psMetadataLookupMetadata(&mdok, config->arguments, "NORMALIZATION.TABLE");
     if (normlist) {
-	pmFPAfile *inputFile = psMetadataLookupPtr(&mdok, config->files, "PPIMAGE.INPUT");
+        pmFPAfile *inputFile = psMetadataLookupPtr(&mdok, config->files, "PPIMAGE.INPUT");
 
-	// get the menu of class IDs
-        psMetadata *menu = psMetadataLookupMetadata(&mdok, inputFile->camera, "CLASSID"); 
+        // get the menu of class IDs
+        psMetadata *menu = psMetadataLookupMetadata(&mdok, inputFile->camera, "CLASSID");
         if (!menu) {
             psError(PS_ERR_IO, false, "Unable to find CLASSID metadata in camera configuration");
-	    psFree(detview);
+            psFree(detview);
             return false;
         }
-	// get the rule for class_id for the desired class
-        const char *rule = psMetadataLookupStr(&mdok, menu, options->normClass); 
+        // get the rule for class_id for the desired class
+        const char *rule = psMetadataLookupStr(&mdok, menu, options->normClass);
         if (!rule) {
             psError(PS_ERR_IO, false, "Unable to find NORM.CLASS value %s in CLASSID in camera configuration", options->normClass);
-	    psFree(detview);
+            psFree(detview);
             return false;
         }
-	// get the class_id from the rule
+        // get the class_id from the rule
         char *classID = pmFPAfileNameFromRule(rule, inputFile, view);
         if (!classID) {
             psError(PS_ERR_IO, false, "error converting CLASSID rule %s to name\n", rule);
-	    psFree(detview);
+            psFree(detview);
             return false;
         }
 
-	// get normalization from the class_id
-	float norm = psMetadataLookupF32 (&mdok, normlist, classID);
-	if (!mdok) {
-	    psError(PS_ERR_IO, false, "failed to find class ID %s in normalization table\n", classID);
-	    psFree(detview);
-	    return false;
-	}
+        // get normalization from the class_id
+        float norm = psMetadataLookupF32 (&mdok, normlist, classID);
+        if (!mdok) {
+            psError(PS_ERR_IO, false, "failed to find class ID %s in normalization table\n", classID);
+            psFree(detview);
+            return false;
+        }
 
         pmHDU *hdu = pmHDUFromReadout(input); // HDU of interest
@@ -157,8 +157,8 @@
         psFree(comment);
 
-	// apply the normalization
+        // apply the normalization
         psBinaryOp(input->image, input->image, "*", psScalarAlloc(norm, PS_TYPE_F32));
 
-	psFree (classID);
+        psFree (classID);
     }
 # endif
@@ -167,5 +167,5 @@
         pmCell *fringe = pmFPAfileThisCell(config->files, detview, "PPIMAGE.FRINGE");
         if (!ppImageDetrendFringeMeasure(input, fringe, false, options)) {
-	    psFree(detview);
+            psFree(detview);
             return false;
         }
