Index: /trunk/ppImage/src/ppImage.c
===================================================================
--- /trunk/ppImage/src/ppImage.c	(revision 6113)
+++ /trunk/ppImage/src/ppImage.c	(revision 6114)
@@ -27,4 +27,5 @@
     ppImageLoop(&data, &options, &config);
 
+#if 0
     // Output image
     ppImageOutput(&data, &config);
@@ -32,4 +33,5 @@
     // Do photometry
     ppImagePhot(&data, &options, &config);
+#endif
 
     exit(EXIT_SUCCESS);
Index: /trunk/ppImage/src/ppImageDetrendCell.c
===================================================================
--- /trunk/ppImage/src/ppImageDetrendCell.c	(revision 6113)
+++ /trunk/ppImage/src/ppImageDetrendCell.c	(revision 6114)
@@ -63,7 +63,4 @@
         // Flat-field correction (no options used?)
         if (options->doFlat) {
-#if 0
-            psLogMsg("phase2", PS_LOG_INFO, "flat field disabled.\n");
-#endif
             pmFlatField(input, flat);
         }
Index: /trunk/ppImage/src/ppImageLoop.c
===================================================================
--- /trunk/ppImage/src/ppImageLoop.c	(revision 6113)
+++ /trunk/ppImage/src/ppImageLoop.c	(revision 6114)
@@ -89,6 +89,24 @@
 
             ppDetrendCell(&detrend, options, config);
+
+            // Need to free detrend cells here so we have enough memory to do other stuff
+            psFree(detrend.bias);
+            psFree(detrend.dark);
+            psFree(detrend.mask);
+            psFree(detrend.flat);
         }
+
+        int numMosaicked = pmChipMosaic(inputChip, 1, 1); // Number of cells mosaicked together
+        psLogMsg(__func__, PS_LOG_INFO, "%d cells mosaicked.\n", numMosaicked);
+
     }
+
+    // Free the detrend FPA and chips
+    psFree(data->bias);
+    psFree(data->dark);
+    psFree(data->mask);
+    psFree(data->flat);
+
+
     return true;
 }
Index: /trunk/ppImage/src/ppImageOutput.c
===================================================================
--- /trunk/ppImage/src/ppImageOutput.c	(revision 6113)
+++ /trunk/ppImage/src/ppImageOutput.c	(revision 6114)
@@ -4,5 +4,5 @@
 {
     const char *outname = psMetadataLookupStr(NULL, config->arguments, "-output"); // Name of output file
-    psFits *outFile = psFitsOpen(outname, "w"); // File for writing
+    psFits *outFile = psFitsOpen(outname, "a"); // File for writing
 
     // Write the output
Index: /trunk/ppImage/src/ppImageParseCamera.c
===================================================================
--- /trunk/ppImage/src/ppImageParseCamera.c	(revision 6113)
+++ /trunk/ppImage/src/ppImageParseCamera.c	(revision 6114)
@@ -55,7 +55,4 @@
     data->flat->fpa    = pmFPAConstruct(config->camera);
     data->fringe->fpa  = pmFPAConstruct(config->camera);
-#if 0
-    data->process->fpa = pmFPAConstruct(config->camera);
-#endif
 
     // XXX EAM : extend this to allow an array of selected chips by name
Index: /trunk/ppImage/src/ppImagePhot.c
===================================================================
--- /trunk/ppImage/src/ppImagePhot.c	(revision 6113)
+++ /trunk/ppImage/src/ppImagePhot.c	(revision 6114)
@@ -6,5 +6,5 @@
     pmFPA *fpa = input->fpa;       // The input FPA
 
-    int numMosaicked = pmFPAMosaicChips(fpa, 1, 1); // Number of chips mosaicked together
+    int numMosaicked = pmFPAMosaicCells(fpa, 1, 1); // Number of chips mosaicked together
     psLogMsg(__func__, PS_LOG_INFO, "%d chips mosaicked.\n", numMosaicked);
 
