Index: /trunk/psphot/src/psphotReadoutFindPSF.c
===================================================================
--- /trunk/psphot/src/psphotReadoutFindPSF.c	(revision 20329)
+++ /trunk/psphot/src/psphotReadoutFindPSF.c	(revision 20330)
@@ -31,15 +31,11 @@
     // XXX this requires sources to be supplied as PSPHOT.INPUT.CMF
     pmDetections *detections = psphotLoadPSFSources (config, view);
-    if (detections == NULL) {
-      psLogMsg ("psphot", 3, "problem loading psf stars");
-      return psphotReadoutCleanup (config, readout, recipe, detections, NULL, NULL);
-    }
-    if (detections->peaks == NULL) {
-      psLogMsg ("psphot", 3, "no psf stars supplied");
-      return psphotReadoutCleanup (config, readout, recipe, detections, NULL, NULL);
+    if (!detections || !detections->peaks) {
+        psError(PSPHOT_ERR_ARGUMENTS, true, "Can't find PSF stars");
+        return psphotReadoutCleanup(config, readout, recipe, detections, NULL, NULL);
     }
 
     // construct sources and measure basic stats (moments, local sky)
-    psArray *sources = psphotSourceStats (readout, recipe, detections);
+    psArray *sources = psphotSourceStats(readout, recipe, detections);
     if (!sources) return false;
 
@@ -51,15 +47,17 @@
     }
 
-    pmPSF *psf = psphotChoosePSF (readout, sources, recipe);
-    if (psf == NULL) {
-      psLogMsg ("psphot", 3, "failure to construct a psf model");
-      return psphotReadoutCleanup (config, readout, recipe, detections, psf, sources);
+    pmPSF *psf = psphotChoosePSF(readout, sources, recipe);
+    if (!psf) {
+        psWarning("Failed to construct a psf model");
+        psFree(sources);
+        return psphotReadoutCleanup(config, readout, recipe, detections, NULL, NULL);
     }
-    psphotVisualShowPSFModel (readout, psf);
+    psphotVisualShowPSFModel(readout, psf);
 
     // drop the references to the image pixels held by each source
-    psphotSourceFreePixels (sources);
+    psphotSourceFreePixels(sources);
+    psFree(sources);
 
     // create the exported-metadata and free local data
-    return psphotReadoutCleanup(config, readout, recipe, detections, psf, sources);
+    return psphotReadoutCleanup(config, readout, recipe, detections, psf, NULL);
 }
