Index: trunk/psModules/src/detrend/pmBias.c
===================================================================
--- trunk/psModules/src/detrend/pmBias.c	(revision 18893)
+++ trunk/psModules/src/detrend/pmBias.c	(revision 18960)
@@ -19,5 +19,7 @@
 #include "pmBias.h"
 
-bool pmBiasSubtractScan_Threaded (psThreadJob *job) {
+bool pmBiasSubtractScan_Threaded(const psThreadJob *job)
+{
+    PS_ASSERT_THREAD_JOB_NON_NULL(job, false);
     pmReadout *in = job->args->data[0];
     pmReadout *sub = job->args->data[1];
@@ -63,6 +65,6 @@
 // image.  The bias image is subtracted in place from the input image.
 bool pmBiasSubtractFrame(pmReadout *in, // Input readout
-			 pmReadout *sub, // Readout to be subtracted from input
-			 float scale   // Scale to apply before subtracting
+                         pmReadout *sub, // Readout to be subtracted from input
+                         float scale   // Scale to apply before subtracting
     )
 {
@@ -121,7 +123,7 @@
     bool threaded = true;
     int scanRows = pmDetrendGetScanRows();
-    if (scanRows == 0) { 
-	threaded = false;
-	scanRows = inImage->numRows;
+    if (scanRows == 0) {
+        threaded = false;
+        scanRows = inImage->numRows;
     }
 
@@ -129,43 +131,40 @@
       int rowStop = PS_MIN (rowStart + scanRows, inImage->numRows);
 
-# define PS_ARRAY_ADD_SCALAR(ARRAY, VALUE, TYPE) { \
-      psScalar *scalar = psScalarAlloc(VALUE, TYPE); \
-      psArrayAdd(ARRAY, 1, scalar); \
-      psFree (scalar); }
-      
       if (threaded) {
-	  // allocate a job, construct the arguments for this job
-	  psThreadJob *job = psThreadJobAlloc ("PSMODULES_DETREND_BIAS");
-	  psArrayAdd (job->args, 1, in);
-	  psArrayAdd (job->args, 1, sub);
-	  PS_ARRAY_ADD_SCALAR (job->args, scale, PS_TYPE_F32);
-	  PS_ARRAY_ADD_SCALAR (job->args, xOffset, PS_TYPE_S32);
-	  PS_ARRAY_ADD_SCALAR (job->args, yOffset, PS_TYPE_S32);
-	  PS_ARRAY_ADD_SCALAR (job->args, rowStart, PS_TYPE_S32);
-	  PS_ARRAY_ADD_SCALAR (job->args, rowStop, PS_TYPE_S32);
-
-	  // ppImageDetrendReadout(config, options, view)
-	  if (!psThreadJobAddPending (job)) {
-	      return false;
-	  }
+          // allocate a job, construct the arguments for this job
+          psThreadJob *job = psThreadJobAlloc ("PSMODULES_DETREND_BIAS");
+          psArrayAdd (job->args, 1, in);
+          psArrayAdd (job->args, 1, sub);
+          PS_ARRAY_ADD_SCALAR (job->args, scale, PS_TYPE_F32);
+          PS_ARRAY_ADD_SCALAR (job->args, xOffset, PS_TYPE_S32);
+          PS_ARRAY_ADD_SCALAR (job->args, yOffset, PS_TYPE_S32);
+          PS_ARRAY_ADD_SCALAR (job->args, rowStart, PS_TYPE_S32);
+          PS_ARRAY_ADD_SCALAR (job->args, rowStop, PS_TYPE_S32);
+
+          // ppImageDetrendReadout(config, options, view)
+          if (!psThreadJobAddPending (job)) {
+              psFree(job);
+              return false;
+          }
+          psFree(job);
       } else {
-	  pmBiasSubtractScan (in, sub, scale, xOffset, yOffset, rowStart, rowStop);
+          pmBiasSubtractScan (in, sub, scale, xOffset, yOffset, rowStart, rowStop);
       }
     }
 
     if (threaded) {
-	// wait here for the threaded jobs to finish
-	if (!psThreadPoolWait ()) {
-	    psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");
-	    return false;
-	}
-	fprintf (stderr, "success for threaded jobs\n");
-
-	// each job records its own goodPixel values; sum them here
-	// we have only supplied one type of job, so we can assume the types here
-	psThreadJob *job = NULL;
-	while ((job = psThreadJobGetDone()) != NULL) {
-	    psFree (job);
-	}
+        // wait here for the threaded jobs to finish
+        if (!psThreadPoolWait(false)) {
+            psError(PS_ERR_UNKNOWN, false, "Unable to interpolate image.");
+            return false;
+        }
+        fprintf (stderr, "success for threaded jobs\n");
+
+        // each job records its own goodPixel values; sum them here
+        // we have only supplied one type of job, so we can assume the types here
+        psThreadJob *job = NULL;
+        while ((job = psThreadJobGetDone()) != NULL) {
+            psFree (job);
+        }
     }
 
