Index: trunk/ppImage/src/ppFocus.c
===================================================================
--- trunk/ppImage/src/ppFocus.c	(revision 7750)
+++ trunk/ppImage/src/ppFocus.c	(revision 7757)
@@ -40,4 +40,5 @@
 	// Image Arithmetic Loop
 	// XXX ppFocus REQUIRES photom: for it to be true?
+	// 
 	if (!ppImageLoop(config, options)) {
 	    psErrorStackPrint(stderr, "");
@@ -58,4 +59,6 @@
 
     // Cleaning up
+    psFree (focus);
+    psFree (fwhm);
     ppImageCleanup(config, NULL);
     return EXIT_SUCCESS;
Index: trunk/ppImage/src/ppFocusFitFWHM.c
===================================================================
--- trunk/ppImage/src/ppFocusFitFWHM.c	(revision 7750)
+++ trunk/ppImage/src/ppFocusFitFWHM.c	(revision 7757)
@@ -7,5 +7,9 @@
     psPolynomial1D *poly = psPolynomial1DAlloc (PS_POLYNOMIAL_ORD, 2);
 
-    psVectorFitPolynomial1D (poly, NULL, 0, fwhm, NULL, focus);
+    poly = psVectorFitPolynomial1D (poly, NULL, 0, fwhm, NULL, focus);
+    if (!poly) {
+	psError (PS_ERR_UNKNOWN, false, "failed to fit focus/fwhm trend; invalid image data?");
+	return false;
+    }
 
     if (poly->coeff[2] <= 0.0) {
@@ -19,4 +23,5 @@
     psLogMsg ("ppFocus", 3, "fwhm @ min: %f\n", psPolynomial1DEval (poly, minFocus));
     
+    psFree (poly);
     return true;
 }
Index: trunk/ppImage/src/ppFocusGetFWHM.c
===================================================================
--- trunk/ppImage/src/ppFocusGetFWHM.c	(revision 7750)
+++ trunk/ppImage/src/ppFocusGetFWHM.c	(revision 7757)
@@ -37,11 +37,9 @@
 
 		// get average FWHM
-		// XXX one option is to use the PSF model to determine the FWHM somewhere
-		# if 0
-		psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF");
-		if (psf == NULL) continue;
-		# endif
-
-		// in this example, we use the supplied PSPHOT.HEADER data in which FWHM_X,Y are supplied
+		// psphotReadout writes the FWHM values into the PSPHOT.HEADER table
+		// the source of this value depends on the psphot options.
+		// - if breakPoint is set to PEAKS, the value will not be defined
+		// - if breakPoint is set to MOMENTS, the PSFSTAR moments are used
+		// - in all other cases, the psf model is used
 		header = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.HEADER");
 		if (header == NULL) {
@@ -63,6 +61,5 @@
     FWHM = FWHMsum / FWHMnum;
 
-    // FOCUS = pmConcepts (&status, input->fpa, "FOCUS");
-    FOCUS = 0;
+    FOCUS = psMetadataLookupF32 (&status, input->fpa->concepts, "FPA.FOCUS");
 
     fwhm->data.F32[fwhm->n] = FWHM;
