Index: /trunk/ppImage/src/ppImage.c
===================================================================
--- /trunk/ppImage/src/ppImage.c	(revision 7638)
+++ /trunk/ppImage/src/ppImage.c	(revision 7639)
@@ -35,2 +35,49 @@
     return EXIT_SUCCESS;
 }
+
+void ppImageFileCheck (pmConfig *config) {
+
+    // add the output names to the output-type files
+    psMetadataItem *item = NULL;
+    psMetadataIterator *iter = psMetadataIteratorAlloc (config->files, PS_LIST_HEAD, NULL);
+    while ((item = psMetadataGetAndIncrement (iter)) != NULL) {
+	pmFPAfile *file = item->data.V;
+	pmFPA *fpa = file->fpa;
+	fprintf (stderr, "file %s\n", file->name);
+	if (!fpa) {
+	    fprintf (stderr, "  has no FPA\n");
+	    continue;
+	}
+	if (fpa->hdu) {
+	    if (fpa->hdu->images) fprintf (stderr, "  (%d,%d) images\n", -1, -1);
+	    if (fpa->hdu->weights) fprintf (stderr, "  (%d,%d) weights\n", -1, -1);
+	    if (fpa->hdu->masks) fprintf (stderr, "  (%d,%d) masks\n", -1, -1);
+	    if (fpa->hdu->header) fprintf (stderr, "  (%d,%d) header\n", -1, -1);
+	    continue;
+	}
+	fprintf (stderr, "  has no fpa data (%d,%d)\n", -1, -1);
+	for (int i = 0; i < fpa->chips->n; i++) {
+	    pmChip *chip = fpa->chips->data[i];
+	    if (chip->hdu) {
+		if (chip->hdu->images) fprintf (stderr, "  (%d,%d) images\n", i, -1);
+		if (chip->hdu->weights) fprintf (stderr, "  (%d,%d) weights\n", i, -1);
+		if (chip->hdu->masks) fprintf (stderr, "  (%d,%d) masks\n", i, -1);
+		if (chip->hdu->header) fprintf (stderr, "  (%d,%d) header\n", i, -1);
+		continue;
+	    }
+	    fprintf (stderr, "  has no chip data (%d,%d)\n", i, -1);
+	    for (int j = 0; j < chip->cells->n; j++) {
+		pmCell *cell = chip->cells->data[j];
+		if (cell->hdu) {
+		    if (cell->hdu->images) fprintf (stderr, "  (%d,%d) images\n", i, j);
+		    if (cell->hdu->weights) fprintf (stderr, "  (%d,%d) weights\n", i, j);
+		    if (cell->hdu->masks) fprintf (stderr, "  (%d,%d) masks\n", i, j);
+		    if (cell->hdu->header) fprintf (stderr, "  (%d,%d) header\n", i, j);
+		    continue;
+		}
+		fprintf (stderr, "  has no cell data (%d,%d)\n", i, j);
+	    }
+	}
+    }
+    psFree (iter);
+}
Index: /trunk/ppImage/src/ppImage.h
===================================================================
--- /trunk/ppImage/src/ppImage.h	(revision 7638)
+++ /trunk/ppImage/src/ppImage.h	(revision 7639)
@@ -43,3 +43,5 @@
 bool ppImageMosaicFPA (pmConfig *config, char *outFile, char *inFile);
 
+void ppImageFileCheck (pmConfig *config);
+
 #endif
Index: /trunk/ppImage/src/ppImageAstrom.c
===================================================================
--- /trunk/ppImage/src/ppImageAstrom.c	(revision 7638)
+++ /trunk/ppImage/src/ppImageAstrom.c	(revision 7639)
@@ -20,6 +20,8 @@
 	input->mode = PM_FPA_MODE_REFERENCE;
 
-	pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.OUTPUT");
+	pmFPAfileDefineOutput (config, input->fpa, "PSASTRO.OUTPUT");
     }
+
+    psastroConvertFPA (input->fpa, recipe);
 
     // interpret the available initial astrometric information
@@ -39,4 +41,7 @@
     }
 
+    psastroDataSave (config);
+
+    psFree (refs);
     return true;
 }
Index: /trunk/ppImage/src/ppImageCleanup.c
===================================================================
--- /trunk/ppImage/src/ppImageCleanup.c	(revision 7638)
+++ /trunk/ppImage/src/ppImageCleanup.c	(revision 7639)
@@ -12,6 +12,6 @@
     pmConfigDone();
     pmModelGroupCleanup();
-    // fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, NULL, false), "ppImage");
-    fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "ppImage");
+    fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, NULL, false), "ppImage");
+    // fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "ppImage");
     return;
 }
Index: /trunk/ppImage/src/ppImageLoop.c
===================================================================
--- /trunk/ppImage/src/ppImageLoop.c	(revision 7638)
+++ /trunk/ppImage/src/ppImageLoop.c	(revision 7639)
@@ -7,4 +7,5 @@
     pmCell *cell;
     pmReadout *readout;
+    psMemId ID;
 
     pmFPAfile *input = psMetadataLookupPtr (&status, config->files, "PPIMAGE.INPUT");
@@ -22,4 +23,6 @@
         psLogMsg ("ppImageLoop", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
         if (!chip->process || !chip->file_exists) { continue; }
+
+	ID = psMemGetId();
 	if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) return false;
 
@@ -36,5 +39,5 @@
 		// perform the detrend analysis
 		if (!ppImageDetrendReadout (config, options, view)) return false;
-
+		
 		if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) return false;
 	    }
@@ -50,4 +53,8 @@
 
 	if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) return false;
+
+	fprintf (stderr, "done chip\n");
+	// fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (ID, NULL, stdout, false), "chips");
+	// ppImageFileCheck (config);
     }
 
@@ -57,5 +64,5 @@
     // we perform astrometry on all chips after sources have been detected
     if (options->doAstromChip || options->doAstromMosaic) ppImageAstrom (config);
-    
+
     if (!pmFPAfileIOChecks (config, view, PM_FPA_AFTER)) return false;
 
Index: /trunk/ppImage/src/ppImageMosaic.c
===================================================================
--- /trunk/ppImage/src/ppImageMosaic.c	(revision 7638)
+++ /trunk/ppImage/src/ppImageMosaic.c	(revision 7639)
@@ -42,4 +42,12 @@
     }
 
+    for (int i = 0; i < in->fpa->chips->n; i++) {
+	pmChip *chip = in->fpa->chips->data[i];
+	for (int j = 0; j < chip->cells->n; j++) {
+	    pmCell *cell = chip->cells->data[j];
+	    psMetadataPrint (stdout, cell->concepts, 2);
+	}
+    }
+
     pmFPAview *view = pmFPAviewAlloc (0);
     pmFPAAddSourceFromView (out->fpa, view, out->format);
Index: /trunk/ppImage/src/ppImagePhotom.c
===================================================================
--- /trunk/ppImage/src/ppImagePhotom.c	(revision 7638)
+++ /trunk/ppImage/src/ppImagePhotom.c	(revision 7639)
@@ -31,5 +31,6 @@
 	input->mode = PM_FPA_MODE_REFERENCE;
 
-	pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.OUTPUT");
+	pmFPAfile *outfile = pmFPAfileDefineOutput (config, input->fpa, "PSPHOT.OUTPUT");
+	outfile->freeLevel = PM_FPA_LEVEL_FPA;
     }
 
@@ -80,4 +81,5 @@
 	    // run the actual photometry analysis
 	    psphotReadout (config, view);
+	    fprintf (stderr, "psphot done\n");
 	}
     }
