Index: trunk/ppSub/src/ppSubBackground.c
===================================================================
--- trunk/ppSub/src/ppSubBackground.c	(revision 21360)
+++ trunk/ppSub/src/ppSubBackground.c	(revision 21524)
@@ -6,36 +6,38 @@
  *
  *  @author IfA
- *  @version $Revision: 1.6 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2009-02-06 01:37:17 $
+ *  @version $Revision: 1.7 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2009-02-18 00:31:20 $
  *  Copyright 2009 Institute for Astronomy, University of Hawaii
  */
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <pslib.h>
+#include <psmodules.h>
+#include <psphot.h>
+
 #include "ppSub.h"
 
-/**
- * Based on ppImageSubtractBackground()
- */
 bool ppSubBackground(pmConfig *config, const pmFPAview *view)
 {
-    psAssert(config, "Need configuration");
-    psAssert(view, "Need view to chip");
+    psAssert(config, "Require configuration");
+    psAssert(view, "Require view");
 
-    bool status; // Status of metadata lookups
+    bool mdok; // Status of metadata lookups
 
-    psMetadata *ppSubRecipe = psMetadataLookupPtr(NULL, config->recipes, PPSUB_RECIPE);
+    psMetadata *ppSubRecipe = psMetadataLookupPtr(NULL, config->recipes, PPSUB_RECIPE); // Recipe for ppSub
     psAssert(ppSubRecipe, "Need PPSUB recipe");
-
-    psMetadata *psphotRecipe = psMetadataLookupPtr(NULL, config->recipes, PSPHOT_RECIPE);
+    psMetadata *psphotRecipe = psMetadataLookupPtr(NULL, config->recipes, PSPHOT_RECIPE); // Recipe for psphot
     psAssert(psphotRecipe, "Need PSPHOT recipe for binning");
 
-    psImageMaskType maskBad = pmConfigMaskGet("BLANK", config); 
+    psImageMaskType maskBad = pmConfigMaskGet("BLANK", config); // Bits to mask
 
-    // select the output readout
-    pmReadout *outRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT");
+    pmReadout *outRO = pmFPAfileThisReadout(config->files, view, "PPSUB.OUTPUT"); // Output image
+    pmReadout *modelRO = pmFPAfileThisReadout(config->files, view, "PSPHOT.BACKMDL"); // Background model
 
-    // select the model readout, if it exist already; if not, generate it
-    pmReadout *modelRO = pmFPAfileThisReadout(config->files, view, "PSPHOT.BACKMDL");
-
-    // if necessary, generate the background model
+    // Generate the background model, if required
     if (!modelRO) {
         // Create the background model
@@ -44,6 +46,6 @@
             return false;
         }
-	// select the model readout (should now exist)
-	modelRO = pmFPAfileThisReadout(config->files, view, "PSPHOT.BACKMDL");
+        // select the model readout (should now exist)
+        modelRO = pmFPAfileThisReadout(config->files, view, "PSPHOT.BACKMDL");
         if (!modelRO) {
             psError(PS_ERR_UNEXPECTED_NULL, true, "Unable to find background model");
@@ -51,8 +53,7 @@
         }
     }
-    psImageBinning *binning = psMetadataLookupPtr(&status, psphotRecipe,
+    psImageBinning *binning = psMetadataLookupPtr(&mdok, psphotRecipe,
                                                   "PSPHOT.BACKGROUND.BINNING"); // Binning for model
     psImage *modelImage = modelRO->image; // Background model
-
     psImage *image = outRO->image; // Image of interest
     psImage *mask = outRO->mask; // Mask of interest
