Index: trunk/ppStack/src/ppStackLoop.c
===================================================================
--- trunk/ppStack/src/ppStackLoop.c	(revision 19476)
+++ trunk/ppStack/src/ppStackLoop.c	(revision 19477)
@@ -467,4 +467,8 @@
 
 
+    // Start threading
+    ppStackThreadInit();
+    ppStackThreadData *stack = ppStackThreadDataSetup(cells, imageNames, maskNames, weightNames, config);
+
     memDump("preinitial");
 
@@ -474,5 +478,4 @@
     pmFPAview *view = NULL;             // View to readout
     psArray *inspect = NULL;            // Array of arrays of pixels to inspect
-    ppStackThreadData *stack = NULL;    // Data for stacking
     psVector *exptimes = psVectorAlloc(num, PS_TYPE_F32); // Exposure times for each input
     {
@@ -487,4 +490,5 @@
             psFree(inputMask);
             psFree(exptimes);
+            psFree(cells);
             return false;
         }
@@ -499,4 +503,5 @@
             psFree(inputMask);
             psFree(exptimes);
+            psFree(cells);
             return false;
         }
@@ -516,4 +521,5 @@
             psFree(outRO);
             psFree(exptimes);
+            psFree(cells);
             return false;
         }
@@ -536,8 +542,5 @@
         psFree(cellList);
 
-        // Start threading
-        ppStackThreadInit();
-        ppStackThreadData *stack = ppStackThreadDataSetup(cells, imageNames, maskNames, weightNames, config);
-        psFree(cells);
+    psFree(cells);
 
         bool status;                    // Status of read
