Index: /trunk/ppStack/src/ppStackCleanup.c
===================================================================
--- /trunk/ppStack/src/ppStackCleanup.c	(revision 26116)
+++ /trunk/ppStack/src/ppStackCleanup.c	(revision 26117)
@@ -4,5 +4,4 @@
 
 #include <stdio.h>
-#include <unistd.h>
 #include <pslib.h>
 #include <psmodules.h>
@@ -22,7 +21,4 @@
     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe
     psAssert(recipe, "We've thrown an error on this before.");
-
-    bool mdok;                          // Status of MD lookup
-    bool tempDelete = psMetadataLookupBool(&mdok, recipe, "TEMP.DELETE"); // Delete temporary files?
 
 #if 0
@@ -72,20 +68,4 @@
             }
         }
-
-        if (tempDelete) {
-            psString imageResolved = pmConfigConvertFilename(options->convImages->data[i],
-                                                             config, false, false);
-            psString maskResolved = pmConfigConvertFilename(options->convMasks->data[i],
-                                                            config, false, false);
-            psString varianceResolved = pmConfigConvertFilename(options->convVariances->data[i],
-                                                                config, false, false);
-            if (unlink(imageResolved) == -1 || unlink(maskResolved) == -1 ||
-                unlink(varianceResolved) == -1) {
-                psWarning("Unable to delete temporary files for image %d", i);
-            }
-            psFree(imageResolved);
-            psFree(maskResolved);
-            psFree(varianceResolved);
-        }
     }
 
Index: /trunk/ppStack/src/ppStackFinish.c
===================================================================
--- /trunk/ppStack/src/ppStackFinish.c	(revision 26116)
+++ /trunk/ppStack/src/ppStackFinish.c	(revision 26117)
@@ -4,4 +4,5 @@
 
 #include <stdio.h>
+#include <unistd.h>
 #include <pslib.h>
 #include <psmodules.h>
@@ -20,4 +21,31 @@
     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe
     psAssert(recipe, "We've thrown an error on this before.");
+
+    bool mdok;                          // Status of MD lookup
+    bool tempDelete = psMetadataLookupBool(&mdok, recipe, "TEMP.DELETE"); // Delete temporary files?
+
+    // Delete temporary images
+    if (tempDelete && options->convolve) {
+        for (int i = 0; i < options->num; i++) {
+            if (options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i]) {
+                continue;
+            }
+
+            psString imageResolved = pmConfigConvertFilename(options->convImages->data[i],
+                                                             config, false, false);
+            psString maskResolved = pmConfigConvertFilename(options->convMasks->data[i],
+                                                            config, false, false);
+            psString varianceResolved = pmConfigConvertFilename(options->convVariances->data[i],
+                                                                config, false, false);
+            if (unlink(imageResolved) == -1 || unlink(maskResolved) == -1 ||
+                unlink(varianceResolved) == -1) {
+                psWarning("Unable to delete temporary files for image %d", i);
+            }
+            psFree(imageResolved);
+            psFree(maskResolved);
+            psFree(varianceResolved);
+        }
+    }
+
 
     // Statistics on output
@@ -44,5 +72,4 @@
     }
 
-
     // Write out summary statistics
     if (options->stats) {
@@ -61,7 +88,5 @@
     }
 
-
     // Dump configuration
-    bool mdok;                          // Status of MD lookup
     psString dump = psMetadataLookupStr(&mdok, config->arguments, "DUMP_CONFIG"); // File for config
     if (dump) {
Index: /trunk/ppStack/src/ppStackLoop.c
===================================================================
--- /trunk/ppStack/src/ppStackLoop.c	(revision 26116)
+++ /trunk/ppStack/src/ppStackLoop.c	(revision 26117)
@@ -106,4 +106,15 @@
     ppStackMemDump("final");
 
+    // Clean up
+    psTrace("ppStack", 2, "Cleaning up after combination....\n");
+    if (!ppStackCleanup(stack, options, config)) {
+        psError(PS_ERR_UNKNOWN, false, "Unable to clean up.");
+        psFree(stack);
+        psFree(options);
+        return false;
+    }
+    psLogMsg("ppStack", PS_LOG_INFO, "Stage 6: Cleanup, WCS & JPEGS: %f sec", psTimerClear("PPSTACK_STEPS"));
+    ppStackMemDump("cleanup");
+
     psFree(stack);
 
@@ -125,5 +136,5 @@
             return false;
         }
-        psLogMsg("ppStack", PS_LOG_INFO, "Stage 6: Unconvolved Stack: %f sec", psTimerClear("PPSTACK_STEPS"));
+        psLogMsg("ppStack", PS_LOG_INFO, "Stage 7: Unconvolved Stack: %f sec", psTimerClear("PPSTACK_STEPS"));
         ppStackMemDump("unconv");
 
@@ -132,15 +143,4 @@
     psFree(options->cells); options->cells = NULL;
 #endif
-
-    // Clean up
-    psTrace("ppStack", 2, "Cleaning up after combination....\n");
-    if (!ppStackCleanup(stack, options, config)) {
-        psError(PS_ERR_UNKNOWN, false, "Unable to clean up.");
-        psFree(stack);
-        psFree(options);
-        return false;
-    }
-    psLogMsg("ppStack", PS_LOG_INFO, "Stage 7: Cleanup, WCS & JPEGS: %f sec", psTimerClear("PPSTACK_STEPS"));
-    ppStackMemDump("cleanup");
 
     // Photometry
