Index: trunk/ppStack/src/ppStackLoop.c
===================================================================
--- trunk/ppStack/src/ppStackLoop.c	(revision 34859)
+++ trunk/ppStack/src/ppStackLoop.c	(revision 34860)
@@ -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);
