Index: trunk/psphot/src/psphotChoosePSF.c
===================================================================
--- trunk/psphot/src/psphotChoosePSF.c	(revision 6950)
+++ trunk/psphot/src/psphotChoosePSF.c	(revision 6964)
@@ -146,4 +146,7 @@
     psMetadataAdd (recipe, PS_LIST_TAIL, "ANGLE",  PS_DATA_F32 | PS_META_REPLACE, "PSF angle",           axes.theta);
     
+    psFree (modelEXT);
+    psFree (modelPSF);
+
     return true;
 }
Index: trunk/psphot/src/psphotCleanup.c
===================================================================
--- trunk/psphot/src/psphotCleanup.c	(revision 6950)
+++ trunk/psphot/src/psphotCleanup.c	(revision 6964)
@@ -6,7 +6,7 @@
     psMemCheckCorruption (true);
     pmModelGroupCleanup ();
-//    psphotOutputCleanup ();
     psTimeFinalize ();
     pmConceptsDone ();
+    pmConfigDone ();
     fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, NULL, false), "psphot");
     // fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "psphot");
Index: trunk/psphot/src/psphotParseCamera.c
===================================================================
--- trunk/psphot/src/psphotParseCamera.c	(revision 6950)
+++ trunk/psphot/src/psphotParseCamera.c	(revision 6964)
@@ -75,4 +75,5 @@
         }
     }
+    psFree (chips);
 
     psTrace(__func__, 1, "Done with psphotParseCamera...\n");
Index: trunk/psphot/src/psphotReadout.c
===================================================================
--- trunk/psphot/src/psphotReadout.c	(revision 6950)
+++ trunk/psphot/src/psphotReadout.c	(revision 6964)
@@ -3,11 +3,6 @@
 bool psphotReadout (pmConfig *config, pmFPAview *view) {
 
-    psArray     *sources  = NULL;
-    psArray     *peaks    = NULL;
-    pmPSF       *psf      = NULL;
-    bool         status;
-
     // select the current recipe
-    psMetadata *recipe  = psMetadataLookupPtr (&status, config->recipes, "PSPHOT");
+    psMetadata *recipe  = psMetadataLookupPtr (NULL, config->recipes, "PSPHOT");
 
     // find the currently selected readout
@@ -28,9 +23,9 @@
 
     // find the peaks in the image
-    peaks = psphotFindPeaks (readout, recipe);
+    psArray *peaks = psphotFindPeaks (readout, recipe);
 
     // construct sources and measure basic stats
     // limit moments analysis by S/N?
-    sources = psphotSourceStats (readout, recipe, peaks);
+    psArray *sources = psphotSourceStats (readout, recipe, peaks);
 
     // classify sources based on moments, brightness
@@ -42,5 +37,5 @@
 
     // use bright stellar objects to measure PSF
-    psf = psphotChoosePSF (readout, sources, recipe);
+    pmPSF *psf = psphotChoosePSF (readout, sources, recipe);
     psphotPSFstats (readout, recipe, psf);
 
@@ -76,7 +71,7 @@
 
     // save the results of the analysis 
-    status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY,    "psphot sources", sources);
-    status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.HEADER",  PS_DATA_METADATA, "header stats", header);
-    status = psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.PSF",     PS_DATA_UNKNOWN,  "psphot psf", psf);
+    psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY,    "psphot sources", sources);
+    psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.HEADER",  PS_DATA_METADATA, "header stats", header);
+    psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.PSF",     PS_DATA_UNKNOWN,  "psphot psf", psf);
 
     // remove internal pmFPAfiles, if created
@@ -85,8 +80,8 @@
 
     // free up the local copies of the data
+    psFree (peaks);
+    psFree (sources);
     psFree (psf);
     psFree (header);
-    psFree (sources);
-    psFree (peaks);
     return true;
 }
Index: trunk/psphot/src/psphotSourceFits.c
===================================================================
--- trunk/psphot/src/psphotSourceFits.c	(revision 6950)
+++ trunk/psphot/src/psphotSourceFits.c	(revision 6964)
@@ -95,4 +95,5 @@
     okDBL  = psphotEvalDBL (tmpSrc, DBL->data[0]);
     okDBL &= psphotEvalDBL (tmpSrc, DBL->data[1]);
+    // XXX should I keep / save the flags set in the eval functions?
 
     // correct first model chisqs for flux trend
@@ -100,5 +101,4 @@
     chiTrend = psPolynomial1DEval (psf->ChiTrend, ONE->params->data.F32[1]);
     ONE->chisqNorm = ONE->chisq / chiTrend;
-    // ONE->chisqNorm = ONE->chisq;
 
     // save chisq for double-star/galaxy comparison
@@ -109,7 +109,6 @@
     chiTrend = psPolynomial1DEval (psf->ChiTrend, ONE->params->data.F32[1]);
     ONE->chisqNorm = ONE->chisq / chiTrend;
-    // ONE->chisqNorm = ONE->chisq;
-
-    psFree (tmpSrc); // XXX should I keep / save the flags set in the eval functions?
+
+    psFree (tmpSrc); 
 
     if (okEXT && okDBL) {
@@ -195,5 +194,5 @@
 
     modelSet = psArrayAlloc (2);
-    // DROP modelSet->n = 0;
+    modelSet->n = 2;
 
     DBL = pmModelCopy (PSF);
