Index: branches/eam_branches/ipp-20121219/ppStack/src/ppStackCombinePrepare.c
===================================================================
--- branches/eam_branches/ipp-20121219/ppStack/src/ppStackCombinePrepare.c	(revision 34857)
+++ branches/eam_branches/ipp-20121219/ppStack/src/ppStackCombinePrepare.c	(revision 34902)
@@ -34,10 +34,13 @@
 /*       options->expRO = NULL; */
 /*     } */
-    pmCell *bkgCell;
-    int bkg_r0,bkg_c0;
-    int bkg_nC,bkg_nR;
+    int bkg_r0 = 0,bkg_c0 = 0;
+    int bkg_nC = 0,bkg_nR = 0;
     if (bkgName) {
       ppStackFileActivationSingle(config, PPSTACK_FILES_BKG, true, 0);
       pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT.BKGMODEL", 0);
+      if (!file)  {
+        psError(PPSTACK_ERR_ARGUMENTS, false, "Output background model selected but no inputs provided.");
+        return false;
+      }
       pmFPAview *view = ppStackFilesIterateDown(config);
       pmReadout *ro = pmFPAviewThisReadout(view,file->fpa);
@@ -47,5 +50,5 @@
       bkg_nC = ro->image->numCols;
       bkg_nR = ro->image->numRows;
-      bkgCell = pmFPAfileThisCell(config->files, view, bkgName); // Bkg cell
+      pmCell *bkgCell = pmFPAfileThisCell(config->files, view, bkgName); // Bkg cell
       
       options->bkgRO = pmReadoutAlloc(bkgCell); // BKG readout
Index: branches/eam_branches/ipp-20121219/ppStack/src/ppStackLoop.c
===================================================================
--- branches/eam_branches/ipp-20121219/ppStack/src/ppStackLoop.c	(revision 34857)
+++ branches/eam_branches/ipp-20121219/ppStack/src/ppStackLoop.c	(revision 34902)
@@ -41,8 +41,9 @@
     if (options->quality) return true; // Can't do anything else
 
+    psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe
+
     // Ensure sufficient inputs
     {
         int numGood = stackSummary(options, "initial combination");
-        psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe
         bool safe = psMetadataLookupBool(NULL, recipe, "SAFE"); // Be safe when combining
         if (safe && numGood <= 1) {
@@ -62,6 +63,8 @@
     }
 
+    bool doBackground = psMetadataLookupBool(NULL, recipe, "BACKGROUND.MODEL");
+
     // Prepare for combination
-    if (!ppStackCombinePrepare("PPSTACK.OUTPUT", "PPSTACK.OUTPUT.EXP", "PPSTACK.OUTPUT.BKGMODEL", PPSTACK_FILES_STACK, stack, options, config)) {
+    if (!ppStackCombinePrepare("PPSTACK.OUTPUT", "PPSTACK.OUTPUT.EXP", doBackground ? "PPSTACK.OUTPUT.BKGMODEL" : NULL, PPSTACK_FILES_STACK, stack, options, config)) {
         psError(psErrorCodeLast(), false, "Unable to prepare for combination.");
         psFree(stack);
@@ -143,5 +146,5 @@
 
     // Generate median background stack here.
-    if (!ppStackCombineBackground(stack, options, config)) {
+    if (doBackground && !ppStackCombineBackground(stack, options, config)) {
       psError(psErrorCodeLast(), false, "Unable to generate median of background images.");
       psFree(stack);
