Index: trunk/psphot/src/apply_psf_model.c
===================================================================
--- trunk/psphot/src/apply_psf_model.c	(revision 4642)
+++ trunk/psphot/src/apply_psf_model.c	(revision 4901)
@@ -14,4 +14,5 @@
     int   Niter = 0;
 
+    psMemoryId id = psMemGetId ();
     psTimerStart ("psphot");
 
@@ -33,4 +34,5 @@
 
     for (int i = 0; i < sources->n; i++) {
+
 	psSource *source = sources->data[i];
 
@@ -39,16 +41,12 @@
 	if (source->type == PS_SOURCE_SATURATED) continue;
 
-	// do I even need to test?
-	if (source->modelPSF != NULL) {
-	  psFree (source->modelPSF);
-	}
-
 	// use the source moments, etc to guess basic model parameters
-	psModel *model  = pmSourceModelGuess (source, psf->type); 
+	psModel *modelFLT  = pmSourceModelGuess (source, psf->type); 
 
 	// set PSF parameters for this model
-	model  = psModelFromPSF (model, psf);
+	psModel *model  = psModelFromPSF (modelFLT, psf);
 	x = model->params->data.F32[2];
 	y = model->params->data.F32[3];
+	psFree (modelFLT);
 
 	// set the fit radius based on the object flux limit and the model
@@ -72,4 +70,5 @@
 	  psLogMsg ("psphot", 3, "PSF fit failed for %f, %f (%d iterations)\n", x, y, model->nIter);
 	  source->type = PS_SOURCE_FAIL_FIT_PSF;  // better choice?
+	  psFree (model);
 	  continue;
 	}
