Index: /branches/eam_branches/ipp-20130419/pswarp/src/pswarpCleanup.c
===================================================================
--- /branches/eam_branches/ipp-20130419/pswarp/src/pswarpCleanup.c	(revision 35538)
+++ /branches/eam_branches/ipp-20130419/pswarp/src/pswarpCleanup.c	(revision 35539)
@@ -19,5 +19,4 @@
   "PSWARP.OUTPUT.BKGMODEL",
   "PSWARP.OUTPUT.SOURCES",
-  "PSPHOT.INPUT",
   "PSPHOT.OUTPUT",
   "PSPHOT.RESID",
Index: /branches/eam_branches/ipp-20130419/pswarp/src/pswarpDefineLayout.c
===================================================================
--- /branches/eam_branches/ipp-20130419/pswarp/src/pswarpDefineLayout.c	(revision 35538)
+++ /branches/eam_branches/ipp-20130419/pswarp/src/pswarpDefineLayout.c	(revision 35539)
@@ -95,7 +95,4 @@
     bool bilevelAstrometry = psMetadataLookupBool (NULL, skycell->fpa->analysis, "ASTROMETRY.BILEVEL");
     
-    // generate the output hdu and contents bits
-    pmFPAAddSourceFromFormat(output->fpa, output->format);
-
     // XXX this is a bit muddled : we are setting up the astrometry elements for the output
     // background model here instead of in pswarpLoadAstrometry, where it would be more natural
@@ -106,13 +103,9 @@
 
     // if we have an output background model, generate hdu, etc and supply astrometry
-    if (bkgModel) {
-	pmFPAAddSourceFromFormat(bkgModel->fpa, bkgModel->format);
-
-	if (bilevelAstrometry) {
-	    // top-level elements of the bkgModel astrometry
-	    bkgModel->fpa->toTPA   = psMemIncrRefCounter (skycell->fpa->toTPA);
-	    bkgModel->fpa->fromTPA = psMemIncrRefCounter (skycell->fpa->fromTPA);
-	    bkgModel->fpa->toSky   = psMemIncrRefCounter (skycell->fpa->toSky);
-	}
+    if (bkgModel && bilevelAstrometry) {
+	// top-level elements of the bkgModel astrometry
+	bkgModel->fpa->toTPA   = psMemIncrRefCounter (skycell->fpa->toTPA);
+	bkgModel->fpa->fromTPA = psMemIncrRefCounter (skycell->fpa->fromTPA);
+	bkgModel->fpa->toSky   = psMemIncrRefCounter (skycell->fpa->toSky);
     }
 
Index: /branches/eam_branches/ipp-20130419/pswarp/src/pswarpLoopBackground.c
===================================================================
--- /branches/eam_branches/ipp-20130419/pswarp/src/pswarpLoopBackground.c	(revision 35538)
+++ /branches/eam_branches/ipp-20130419/pswarp/src/pswarpLoopBackground.c	(revision 35539)
@@ -167,5 +167,5 @@
 	}
 
-	if (false && !pswarpUpdateMetadata (output->fpa, skycell->fpa, input->fpa, astrom->fpa, config, false)) {
+	if (!pswarpUpdateMetadata (output->fpa, skycell->fpa, input->fpa, astrom->fpa, config, false)) {
 	    psError(psErrorCodeLast(), false, "problem generating statistics.");
 	    goto FAIL;
Index: /branches/eam_branches/ipp-20130419/pswarp/src/pswarpOptions.c
===================================================================
--- /branches/eam_branches/ipp-20130419/pswarp/src/pswarpOptions.c	(revision 35538)
+++ /branches/eam_branches/ipp-20130419/pswarp/src/pswarpOptions.c	(revision 35539)
@@ -70,9 +70,15 @@
     }
 
-    bool doBKG = psMetadataLookupBool(&status,recipe, "BACKGROUND.MODEL"); ///< Generate the warped background model?
+    // BACKGROUND.MODEL gets set in config->arguments (to false) if no input model is found
+    bool doBKG = psMetadataLookupBool(&status,config->arguments, "BACKGROUND.MODEL"); ///< Generate the warped background model?
     if (!status) {
-      doBKG = false;
+      // if it is not in config->arguments, look in recipe
+      doBKG = psMetadataLookupBool(&status,recipe, "BACKGROUND.MODEL"); ///< Generate the warped background model?
+      if (!status) {
+	doBKG = false;
       psWarning("BACKGROUND.MODEL is not set in the %s recipe -- defaulting to FALSE.", PSWARP_RECIPE);
+      }
     }
+
     int bkgXgrid = psMetadataLookupS32(&status,recipe, "BKG.XGRID"); ///< Xsize of background model
     if (!status) {
Index: /branches/eam_branches/ipp-20130419/pswarp/src/pswarpParseCamera.c
===================================================================
--- /branches/eam_branches/ipp-20130419/pswarp/src/pswarpParseCamera.c	(revision 35538)
+++ /branches/eam_branches/ipp-20130419/pswarp/src/pswarpParseCamera.c	(revision 35539)
@@ -76,4 +76,5 @@
     }
     output->save = true;
+    pmFPAAddSourceFromFormat(output->fpa, output->format); // ** builds the HDUs, is this OK?
 
     pmFPAfile *outMask = useInputCamera ?
@@ -116,12 +117,12 @@
 	    pmFPAfileDefineSkycell(config, NULL, "PSWARP.OUTPUT.BKGMODEL"):
 	    pmFPAfileDefineOutputForFormat(config, NULL, "PSWARP.OUTPUT.BKGMODEL", skycell->cameraName, skycell->formatName);
+	if (!outBackground) {
+	    psError(psErrorCodeLast(), false, "Failed to build FPA from PSWARP.OUTPUT.BKGMODEL");
+	    return false;
+	}
 	outBackground->xBin = psMetadataLookupS32(&status, recipe, "BKG.XGRID");
 	outBackground->yBin = psMetadataLookupS32(&status, recipe, "BKG.YGRID");
-	
-	if (!outBackground) {
-	    psError(psErrorCodeLast(), false, "Failed to build FPA from PSWARP.OUTPUT.BKGMODEL");
-	    return false;
-	}
 	outBackground->save = true;
+	pmFPAAddSourceFromFormat(outBackground->fpa, outBackground->format); // ** builds the HDUs, is this OK?
     }
 
@@ -136,4 +137,5 @@
         }
         psphotInput->src = psMemIncrRefCounter(output->fpa);
+	pmFPAAddSourceFromFormat(psphotInput->fpa, psphotInput->format); // ** builds the HDUs, is this OK?
 
         // specify the number of psphot input images (psphotReadout loops over all input images)
@@ -232,4 +234,6 @@
 	foundBackground = true;
     } else {
+      // cannot do the background model if an input is not supplied.
+      psMetadataAddBool (config->arguments, PS_LIST_TAIL, "BACKGROUND.MODEL", PS_META_REPLACE, "no input background supplied", false);
       psLogMsg("pswarp", PS_LOG_INFO, "No background models supplied");
     }
@@ -329,4 +333,7 @@
 	    psLogMsg("pswarp", PS_LOG_INFO, "No variance supplied");
 	}
+
+	// XXX for now we do not have an option to supply a background model set in multi input mode
+	psMetadataAddBool (config->arguments, PS_LIST_TAIL, "BACKGROUND.MODEL", PS_META_REPLACE, "no input background supplied", false);
     }
 
