Index: trunk/ppImage/src/ppImageLoop.c
===================================================================
--- trunk/ppImage/src/ppImageLoop.c	(revision 6114)
+++ trunk/ppImage/src/ppImageLoop.c	(revision 6125)
@@ -1,3 +1,14 @@
 # include "ppImage.h"
+
+psMemId ppMemPrint(const psMemBlock *ptr)
+{
+    psLogMsg(__func__, PS_LOG_INFO,
+             "Memory block %d (%ld):\n"
+             "\tFile %s, line %d, size %d\n"
+             "\tPosts: %lx %lx %lx\n",
+             ptr->id, ptr->refCounter, ptr->file, ptr->lineno, ptr->userMemorySize, ptr->startblock,
+             ptr->endblock, *(void**)((int8_t *)(ptr + 1) + ptr->userMemorySize));
+    return 0;
+}
 
 // Read the entire FPA
@@ -51,4 +62,9 @@
     psArray *chips = data->input->fpa->chips; // Component chips
     for (int i = 0; i < chips->n; i++) {
+
+        if (i > 6) {
+            continue;
+        }
+
         if (processChip >= 0 && i != processChip) {
             continue;
@@ -100,5 +116,38 @@
         psLogMsg(__func__, PS_LOG_INFO, "%d cells mosaicked.\n", numMosaicked);
 
+        // XXX EAM: Photometry goes here!
+
+        // A kludge to get the write to behave wrt the concepts
+        const psMetadata *camera = data->input->fpa->camera;
+        data->input->fpa->camera = NULL;
+        pmFPAWrite(data->output, data->input->fpa, config->database);
+        data->input->fpa->camera = camera;
+
+        // Now I can blow away the mosaic so I can then read more.
+        psFree(chips->data[i]);
+        ppMemPrint((psMemBlock*)chips->data[i]-1);
     }
+
+#if 0
+    // Write out the mosaicked chip, just to see; this wouldn't normally happen
+    psFits *mosaicFile = psFitsOpen("mosaic.fits", "w");
+    for (int i = 0; i < chips->n; i++) {
+        pmChip *chip = chips->data[i];
+        if (! chip || ! chip->exists || ! chip->process) {
+            continue;
+        }
+#if 0
+        psArray *cells = chip->cells;
+        pmCell *cell = cells->data[0];
+        psArray *readouts = cell->readouts;
+        pmReadout *readout = readouts->data[0];
+        psImage *image = readout->image;
+#else
+        psImage *image = chip->hdu->images->data[0];
+#endif
+        psFitsWriteImage(mosaicFile, NULL, image, 0);
+
+    }
+#endif
 
     // Free the detrend FPA and chips
@@ -108,4 +157,5 @@
     psFree(data->flat);
 
+    psFitsClose(data->output);
 
     return true;
