Index: trunk/psphot/src/psphotImageLoop.c
===================================================================
--- trunk/psphot/src/psphotImageLoop.c	(revision 20642)
+++ trunk/psphot/src/psphotImageLoop.c	(revision 20769)
@@ -72,4 +72,14 @@
 		}
 	    }
+
+	    status = true;
+	    status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL");
+	    status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV");
+	    status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND");
+	    if (!status) {
+		psError(PSPHOT_ERR_PROG, false, "trouble dropping internal files");
+		psFree (view);
+		return false;
+	    }
 	}
 
Index: trunk/psphot/src/psphotReadoutCleanup.c
===================================================================
--- trunk/psphot/src/psphotReadoutCleanup.c	(revision 20642)
+++ trunk/psphot/src/psphotReadoutCleanup.c	(revision 20769)
@@ -7,16 +7,4 @@
 
     // remove internal pmFPAfiles, if created
-    bool status = true;
-    status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL");
-    status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKMDL.STDEV");
-    status &= pmFPAfileDropInternal (config->files, "PSPHOT.BACKGND");
-    if (!status) {
-	psError(PSPHOT_ERR_PROG, false, "trouble dropping internal files");
-	psFree (psf);
-	psFree (sources);
-	psFree (detections);
-	return false;
-    }
-
     if (psErrorCodeLast() == PSPHOT_ERR_DATA) {
         psErrorStackPrint(stderr, "Error in the psphot readout analysis");
