Index: branches/czw_branch/cleanup/ppStack/src/ppStackMatch.c
===================================================================
--- branches/czw_branch/cleanup/ppStack/src/ppStackMatch.c	(revision 24713)
+++ branches/czw_branch/cleanup/ppStack/src/ppStackMatch.c	(revision 24951)
@@ -512,17 +512,20 @@
         psBinaryOp(readout->variance, readout->variance, "*", psScalarAlloc(PS_SQR(norm), PS_TYPE_F32));
     }
-
+   
     // Ensure the background value is zero
     psStats *bg = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics for background
     psRandom *rng = psRandomAlloc(PS_RANDOM_TAUS); // Random number generator
     if (!psImageBackground(bg, NULL, readout->image, readout->mask, maskVal | maskBad, rng)) {
-        psWarning("Can't measure background for image.");
-        psErrorClear();
+      psWarning("Can't measure background for image.");
+      psErrorClear();
     } else {
-        psLogMsg("ppStack", PS_LOG_INFO, "Correcting convolved image background by %lf (+/- %lf)",
-                 psStatsGetValue(bg, PS_STAT_ROBUST_MEDIAN), psStatsGetValue(bg, PS_STAT_ROBUST_STDEV));
-        (void)psBinaryOp(readout->image, readout->image, "-",
-                         psScalarAlloc(psStatsGetValue(bg, PS_STAT_ROBUST_MEDIAN), PS_TYPE_F32));
-    }
+      if (!psMetadataLookupBool(NULL, config->arguments, "PPSTACK.SKIP.BG.SUB")) {
+	psLogMsg("ppStack", PS_LOG_INFO, "Correcting convolved image background by %lf (+/- %lf)",
+		 psStatsGetValue(bg, PS_STAT_ROBUST_MEDIAN), psStatsGetValue(bg, PS_STAT_ROBUST_STDEV));
+	(void)psBinaryOp(readout->image, readout->image, "-",
+			 psScalarAlloc(psStatsGetValue(bg, PS_STAT_ROBUST_MEDIAN), PS_TYPE_F32));
+      }
+    }
+    
 
     // Measure the variance level for the weighting
Index: branches/czw_branch/cleanup/ppStack/src/ppStackThread.c
===================================================================
--- branches/czw_branch/cleanup/ppStack/src/ppStackThread.c	(revision 24713)
+++ branches/czw_branch/cleanup/ppStack/src/ppStackThread.c	(revision 24951)
@@ -187,8 +187,9 @@
 
 
+		int zMax = 0;
                 bool keepReading = false;
-                if (pmReadoutMore(ro, imageFits, 0, rows, config)) {
+                if (pmReadoutMore(ro, imageFits, 0, &zMax, rows, config)) {
                     keepReading = true;
-                    if (!pmReadoutReadChunk(ro, imageFits, 0, rows, overlap, config)) {
+                    if (!pmReadoutReadChunk(ro, imageFits, 0, NULL, rows, overlap, config)) {
                         psError(PS_ERR_IO, false, "Unable to read chunk %d for file PPSTACK.INPUT %d",
                                 numChunk, i);
@@ -198,7 +199,7 @@
                 }
 
-                if (pmReadoutMoreMask(ro, maskFits, 0, rows, config)) {
+                if (pmReadoutMoreMask(ro, maskFits, 0, &zMax, rows, config)) {
                     keepReading = true;
-                    if (!pmReadoutReadChunkMask(ro, maskFits, 0, rows, overlap, config)) {
+                    if (!pmReadoutReadChunkMask(ro, maskFits, 0, NULL, rows, overlap, config)) {
                         psError(PS_ERR_IO, false, "Unable to read chunk %d for file PPSTACK.INPUT.MASK %d",
                                 numChunk, i);
@@ -208,7 +209,7 @@
                 }
 
-                if (pmReadoutMoreVariance(ro, varianceFits, 0, rows, config)) {
+                if (pmReadoutMoreVariance(ro, varianceFits, 0, &zMax, rows, config)) {
                     keepReading = true;
-                    if (!pmReadoutReadChunkVariance(ro, varianceFits, 0, rows, overlap, config)) {
+                    if (!pmReadoutReadChunkVariance(ro, varianceFits, 0, NULL, rows, overlap, config)) {
                         psError(PS_ERR_IO, false,
                                 "Unable to read chunk %d for file PPSTACK.INPUT.VARIANCE %d",
