Index: trunk/psphot/src/psphotFitSourcesLinear.c
===================================================================
--- trunk/psphot/src/psphotFitSourcesLinear.c	(revision 32990)
+++ trunk/psphot/src/psphotFitSourcesLinear.c	(revision 32996)
@@ -216,6 +216,4 @@
     psLogMsg ("psphot.ensemble", PS_LOG_MINUTIA, "built fitSources: %f sec (%ld objects)\n", psTimerMark ("psphot.linear"), sources->n);
 
-    // fprintf (stderr, "****** Nsat : %d ********\n", Nsat);
-
     if (fitSources->n == 0) {
         psFree(fitSources);
Index: trunk/psphot/src/psphotForcedReadout.c
===================================================================
--- trunk/psphot/src/psphotForcedReadout.c	(revision 32990)
+++ trunk/psphot/src/psphotForcedReadout.c	(revision 32996)
@@ -55,5 +55,6 @@
     psphotLoadExtSources (config, view, filerule);
 
-    // construct an initial model for each object, set the radius to fitRadius, set circular fit mask
+    // Construct an initial model for each object, set the radius to fitRadius, set circular
+    // fit mask.  NOTE: only applied to sources without guess models
     psphotGuessModels (config, view, filerule);
 
Index: trunk/psphot/src/psphotGuessModels.c
===================================================================
--- trunk/psphot/src/psphotGuessModels.c	(revision 32990)
+++ trunk/psphot/src/psphotGuessModels.c	(revision 32996)
@@ -46,5 +46,5 @@
     psAssert (detections, "missing detections?");
 
-    psArray *sources = detections->newSources;
+    psArray *sources = detections->allSources;
     psAssert (sources, "missing sources?");
 
@@ -160,4 +160,7 @@
         pmSource *source = sources->data[i];
 
+	// do not redo sources already guessed
+	if (source->tmpFlags & PM_SOURCE_TMPF_MODEL_GUESS) continue;
+
         // this is used to mark sources for which the model is measured. We check later that
         // all are used.
Index: trunk/psphot/src/psphotKronIterate.c
===================================================================
--- trunk/psphot/src/psphotKronIterate.c	(revision 32990)
+++ trunk/psphot/src/psphotKronIterate.c	(revision 32996)
@@ -111,10 +111,7 @@
 
         pmSource *source = sources->data[i];
-        if (!source->peak) continue; // XXX how can we have a peak-less source?
-
-        // allocate space for moments
-        if (!source->moments) continue;
 
 	// set a window function for each source based on the moments
+	// (this skips really bad sources (no peak, no moments, DEFECT)
 	psphotKronWindowSetSource (source, kronWindow, false, true);
     }
@@ -401,5 +398,8 @@
 
     if (!source) return false;
+    if (!source->peak) return false; // XXX how can we have a peak-less source?
     if (!source->moments) return false;
+    if (source->type == PM_SOURCE_TYPE_DEFECT) return false;
+    if (source->type == PM_SOURCE_TYPE_SATURATED) return false;
     psAssert(kronWindow, "need a window");
 
Index: trunk/psphot/src/psphotRadialProfileWings.c
===================================================================
--- trunk/psphot/src/psphotRadialProfileWings.c	(revision 32990)
+++ trunk/psphot/src/psphotRadialProfileWings.c	(revision 32996)
@@ -80,7 +80,7 @@
     }
 
-    MIN_RADIUS = 0.25*psMetadataLookupF32 (&status, readout->analysis, "PSF_MOMENTS_RADIUS");
+    MIN_RADIUS = psMetadataLookupF32 (&status, readout->analysis, "PSF_MOMENTS_RADIUS");
     if (!status) {
-        MIN_RADIUS = 0.25*psMetadataLookupF32 (&status, recipe, "PSF_MOMENTS_RADIUS");
+        MIN_RADIUS = psMetadataLookupF32 (&status, recipe, "PSF_MOMENTS_RADIUS");
     }
 
@@ -209,4 +209,6 @@
 # define TEST_Y 3096
 
+float InterpolateValues (float X0, float Y0, float X1, float Y1, float X);
+
 // XXX use integer radius values?  the rings assume integer values, right? or do they?
 bool psphotRadialProfileWingsSource (pmSource *source, pmReadout *readout, psImageMaskType maskVal) {
@@ -226,5 +228,5 @@
 
     // radii will be MIN_RADIUS to MAX_RADIUS in NN log steps:
-    float NSTEP = 10.0;
+    float NSTEP = 25.0;
     float MIN_DR = 2;
     float NSIGMA = 1.0;
@@ -288,8 +290,25 @@
 	// fprintf (stderr, "%f %f : %f : %f %f  :  %f\n", source->peak->xf, source->peak->yf, radius, meanFlux, meanFluxError, slope);
 
-	if (!limit) {
-	    limit |= (meanFlux - NSIGMA * meanFluxError < THRESHOLD); // dropped to sky level
-	    limit |= isfinite(slope) && (fabs(slope) < 3.0); // SB no longer changing.
-	    limitRadius = meanRadius;
+	if (!limit && (meanFlux - NSIGMA * meanFluxError < THRESHOLD)) {
+	    // dropped to sky level
+	    limit = true;
+	    // linearly interpolate to the radius at which we hit the sky
+	    if (isfinite(lastFlux)) {
+		limitRadius = InterpolateValues(lastFlux, lastRadius, meanFlux, meanRadius, 0.0);
+	    } else {
+		limitRadius = meanRadius;
+	    }
+	    limitFlux = meanFlux;
+	    limitSlope = slope;
+	}
+	if (!limit && isfinite(slope) && (fabs(slope) < 3.0)) { 
+	    // SB no longer changing.	    
+	    limit = true;
+	    // linearly interpolate to the radius at which we hit the sky, using the last flux and the limiting slope
+	    if (isfinite(lastFlux)) {
+		limitRadius = lastRadius + lastFlux / 3.0;
+	    } else {
+		limitRadius = meanRadius;
+	    }
 	    limitFlux = meanFlux;
 	    limitSlope = slope;
Index: trunk/psphot/src/psphotReadout.c
===================================================================
--- trunk/psphot/src/psphotReadout.c	(revision 32990)
+++ trunk/psphot/src/psphotReadout.c	(revision 32996)
@@ -127,11 +127,11 @@
     // psphotLoadExtSources (config, view, filerule); // pass 1
 
-    // construct an initial model for each object, set the radius to fitRadius, set circular
-    // fit mask (detections->newSources)
-    psphotGuessModels (config, view, filerule); // pass 1
-
     // merge the newly selected sources into the existing list
     // NOTE: merge OLD and NEW
     psphotMergeSources (config, view, filerule);
+
+    // Construct an initial model for each object, set the radius to fitRadius, set circular
+    // fit mask.  NOTE: only applied to sources without guess models
+    psphotGuessModels (config, view, filerule); // pass 1
 
     // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
@@ -193,8 +193,4 @@
 	}
 
-	// create full input models, set the radius to fitRadius, set circular fit mask
-	// NOTE: apply only to detections->newSources
-	psphotGuessModels (config, view, filerule); // pass 2 (detections->newSources)
-
 	// replace all sources so fit below applies to all at once
 	// NOTE: apply only to OLD sources (which have been subtracted)
@@ -205,4 +201,8 @@
 	// XXX check on free of sources...
 	psphotMergeSources (config, view, filerule); // (detections->newSources + detections->allSources -> detections->allSources)
+
+	// Construct an initial model for each object, set the radius to fitRadius, set circular
+	// fit mask.  NOTE: only applied to sources without guess models
+	psphotGuessModels (config, view, filerule); // pass 1
 
 	// NOTE: apply to ALL sources
@@ -234,8 +234,4 @@
 	}
 
-	// create full input models, set the radius to fitRadius, set circular fit mask
-	// NOTE: apply only to detections->newSources
-	psphotGuessModels (config, view, filerule); // pass 2 (detections->newSources)
-
 	// replace all sources so fit below applies to all at once
 	// NOTE: apply only to OLD sources (which have been subtracted)
@@ -247,4 +243,8 @@
 	psphotMergeSources (config, view, filerule); // (detections->newSources + detections->allSources -> detections->allSources)
 
+	// Construct an initial model for each object, set the radius to fitRadius, set circular
+	// fit mask.  NOTE: only applied to sources without guess models
+	psphotGuessModels (config, view, filerule); // pass 1
+
 	// NOTE: apply to ALL sources
 	psphotFitSourcesLinear (config, view, filerule, true); // pass 3 (detections->allSources)
Index: trunk/psphot/src/psphotReadoutFindPSF.c
===================================================================
--- trunk/psphot/src/psphotReadoutFindPSF.c	(revision 32990)
+++ trunk/psphot/src/psphotReadoutFindPSF.c	(revision 32996)
@@ -54,4 +54,8 @@
     }
 
+    // merge the newly selected sources into the existing list
+    // NOTE: merge OLD and NEW
+    psphotMergeSources (config, view, filerule); 
+
 # if 0
     // XXX if we want to determine the aperture residual correction here, we either
@@ -61,8 +65,4 @@
     psphotGuessModels (config, view, filerule);
 # endif
-
-    // merge the newly selected sources into the existing list
-    // NOTE: merge OLD and NEW
-    psphotMergeSources (config, view, filerule); 
 
 # if 0
Index: trunk/psphot/src/psphotReadoutForcedKnownSources.c
===================================================================
--- trunk/psphot/src/psphotReadoutForcedKnownSources.c	(revision 32990)
+++ trunk/psphot/src/psphotReadoutForcedKnownSources.c	(revision 32996)
@@ -36,10 +36,11 @@
     }
 
-    // construct an initial model for each object
-    psphotGuessModels (config, view, filerule);
-
     // merge the newly selected sources into the existing list
     // NOTE: merge OLD and NEW
     psphotMergeSources (config, view, filerule); 
+
+    // Construct an initial model for each object, set the radius to fitRadius, set circular
+    // fit mask.  NOTE: only applied to sources without guess models
+    psphotGuessModels (config, view, filerule);
 
     // linear PSF fit to source peaks
Index: trunk/psphot/src/psphotReadoutKnownSources.c
===================================================================
--- trunk/psphot/src/psphotReadoutKnownSources.c	(revision 32990)
+++ trunk/psphot/src/psphotReadoutKnownSources.c	(revision 32996)
@@ -48,10 +48,11 @@
     }
 
-    // construct an initial model for each object
-    psphotGuessModels (config, view, filerule);
-
     // merge the newly selected sources into the existing list
     // NOTE: merge OLD and NEW
     psphotMergeSources (config, view, filerule); 
+
+    // Construct an initial model for each object, set the radius to fitRadius, set circular
+    // fit mask.  NOTE: only applied to sources without guess models
+    psphotGuessModels (config, view, filerule);
 
     // linear PSF fit to source peaks
Index: trunk/psphot/src/psphotReadoutMinimal.c
===================================================================
--- trunk/psphot/src/psphotReadoutMinimal.c	(revision 32990)
+++ trunk/psphot/src/psphotReadoutMinimal.c	(revision 32996)
@@ -59,9 +59,10 @@
     }
 
-    // construct an initial model for each object
-    psphotGuessModels (config, view, filerule);
-
     // merge the newly selected sources into the existing list
     psphotMergeSources (config, view, filerule);
+
+    // Construct an initial model for each object, set the radius to fitRadius, set circular
+    // fit mask.  NOTE: only applied to sources without guess models
+    psphotGuessModels (config, view, filerule);
 
     // linear PSF fit to source peaks
Index: trunk/psphot/src/psphotSourceMatch.c
===================================================================
--- trunk/psphot/src/psphotSourceMatch.c	(revision 32990)
+++ trunk/psphot/src/psphotSourceMatch.c	(revision 32996)
@@ -261,4 +261,5 @@
 	    source->imageID = index;
 	    source->mode2 |= PM_SOURCE_MODE2_MATCHED; // source is generated based on another image
+	    source->type = PM_SOURCE_TYPE_STAR; // until we know more, assume a PSF fit
 
 	    // add the peak
Index: trunk/psphot/src/psphotStackMatchPSFsNext.c
===================================================================
--- trunk/psphot/src/psphotStackMatchPSFsNext.c	(revision 32990)
+++ trunk/psphot/src/psphotStackMatchPSFsNext.c	(revision 32996)
@@ -51,4 +51,6 @@
 
     bool status = false;
+
+    psTimerStart ("psphot.smooth");
 
     // find the currently selected readout
Index: trunk/psphot/src/psphotStackReadout.c
===================================================================
--- trunk/psphot/src/psphotStackReadout.c	(revision 32990)
+++ trunk/psphot/src/psphotStackReadout.c	(revision 32996)
@@ -160,10 +160,11 @@
     }
 
-    // construct an initial model for each object, set the radius to fitRadius, set circular fit mask
-    psphotGuessModels (config, view, STACK_SRC);
-
     // merge the newly selected sources into the existing list
     // NOTE: merge OLD and NEW
     psphotMergeSources (config, view, STACK_SRC);
+
+    // Construct an initial model for each object, set the radius to fitRadius, set circular
+    // fit mask.  NOTE: only applied to sources without guess models
+    psphotGuessModels (config, view, STACK_SRC);
 
     // linear PSF fit to source peaks, subtract the models from the image (in PSF mask)
@@ -248,8 +249,4 @@
 	}
 
-	// create full input models, set the radius to fitRadius, set circular fit mask
-	// NOTE: apply only to detections->newSources
-	psphotGuessModels (config, view, STACK_SRC); // pass 2 (detections->newSources)
-
 	// replace all sources so fit below applies to all at once
 	// NOTE: apply only to OLD sources (which have been subtracted)
@@ -260,4 +257,8 @@
 	// XXX check on free of sources...
 	psphotMergeSources (config, view, STACK_SRC); // (detections->newSources + detections->allSources -> detections->allSources)
+
+	// Construct an initial model for each object, set the radius to fitRadius, set circular
+	// fit mask.  NOTE: only applied to sources without guess models
+	psphotGuessModels (config, view, STACK_SRC);
     }
 
@@ -269,4 +270,8 @@
     objects = psphotMatchSources (config, view, STACK_SRC);
     psMemDump("matchsources");
+
+    // Construct an initial model for each object, set the radius to fitRadius, set circular
+    // fit mask.  NOTE: only applied to sources without guess models
+    psphotGuessModels (config, view, STACK_SRC);
 
     psphotStackObjectsUnifyPosition (objects);
