Index: trunk/psphot/src/psphotChoosePSF.c
===================================================================
--- trunk/psphot/src/psphotChoosePSF.c	(revision 18582)
+++ trunk/psphot/src/psphotChoosePSF.c	(revision 18865)
@@ -64,5 +64,5 @@
     assert (status);
 
-    // XXX ROBUST seems to be too agressive given the small numbers.  
+    // XXX ROBUST seems to be too agressive given the small numbers.
     // options->stats = psStatsAlloc (PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV);
     options->stats = psStatsAlloc (PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV);
@@ -74,5 +74,15 @@
     options->psfFieldYo = readout->image->row0;
 
-    pmSourceFitModelInit (15, 0.01, PS_SQR(SKY_SIG), options->poissonErrorsPhotLMM);
+    int fitIter = psMetadataLookupS32(&status, recipe, "PSF_FIT_ITER"); // Maximum number of fit iterations
+    if (!status || fitIter <= 0) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "PSF_FIT_ITER is not positive");
+        return false;
+    }
+    float fitTol = psMetadataLookupF32 (&status, recipe, "PSF_FIT_TOL"); // Fit tolerance
+    if (!status || !isfinite(fitTol) || fitTol <= 0) {
+        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "PSF_FIT_TOL is not positive");
+        return false;
+    }
+    pmSourceFitModelInit(fitIter, fitTol, PS_SQR(SKY_SIG), options->poissonErrorsPhotLMM);
 
     psArray *stars = psArrayAllocEmpty (sources->n);
@@ -188,11 +198,11 @@
         bool mdok;                      // Status of MD lookup
         if (!psMetadataLookupBool(&mdok, recipe, PSPHOT_RECIPE_PSF_FAKE_ALLOW)) {
-	    psFree (modelNames);
-	    psFree(options);
+            psFree (modelNames);
+            psFree(options);
             return NULL;
         }
 
         // generate a psf model using the first selection
-	psLogMsg ("psphot.pspsf", PS_LOG_INFO, "Using guess PSF model");
+        psLogMsg ("psphot.pspsf", PS_LOG_INFO, "Using guess PSF model");
 
         // unset the PSFSTAR flags (none are used):
