Index: trunk/psphot/src/psphotReadout.c
===================================================================
--- trunk/psphot/src/psphotReadout.c	(revision 31452)
+++ trunk/psphot/src/psphotReadout.c	(revision 32348)
@@ -102,18 +102,4 @@
         return psphotReadoutCleanup (config, view, filerule);
     }
-
-# if (0)
-    // XXX test to mask outliers, not very helpful
-    // mask the high values in the image (with MARK)
-    if (!psphotMaskBackground (config, view, filerule)) {
-        return psphotReadoutCleanup (config, view, filerule);
-    }
-
-    // generate a background model (median, smoothed image)
-    if (!psphotModelBackground (config, view, filerule)) {
-        return psphotReadoutCleanup (config, view, filerule);
-    }
-# endif
-
     if (!psphotSubtractBackground (config, view, filerule)) {
         return psphotReadoutCleanup (config, view, filerule);
@@ -137,5 +123,7 @@
     }
 
-    // construct sources and measure basic stats (saved on detections->newSources)
+    // construct sources and measure moments and other basic stats (saved on detections->newSources)
+    // all sources use the auto-scaled window appropriate to a PSF, except for the saturated
+    // stars : these use a larger window (3x the basic window)
     if (!psphotSourceStats (config, view, filerule, true)) { // pass 1
         psError(PSPHOT_ERR_UNKNOWN, false, "failure to generate sources");
@@ -153,5 +141,7 @@
 
     // mark blended peaks PS_SOURCE_BLEND (detections->newSources)
-    if (!psphotBasicDeblend (config, view, filerule)) {
+    // XXX I've deactivated this because it was preventing galaxies close to stars from being
+    // XXX fitted as an extended source.
+    if (false && !psphotBasicDeblend (config, view, filerule)) {
         psError (PSPHOT_ERR_UNKNOWN, false, "failed on deblend analysis");
         return psphotReadoutCleanup (config, view, filerule);
@@ -200,6 +190,9 @@
     psphotDumpChisqs (config, view, filerule);
 
-    // XXX re-measure the kron mags with models subtracted
-    psphotKronMasked(config, view, filerule);
+    // re-measure the kron mags with models subtracted.  this pass uses a circular window of size PSF_MOMENTS_RADIUS (same window used to measure the psf-scale moments)
+    
+    // but this is chosen above to be appropriate for the PSF objects (not galaxies)
+    // psphotKronMasked(config, view, filerule);
+    psphotKronIterate(config, view, filerule);
 
     // identify CRs and extended sources (only unmeasured sources are measured)
@@ -240,5 +233,5 @@
 	psphotSubNoise (config, view, filerule); // pass 1 (detections->allSources)
 
-	// define new sources based on only the new peaks
+	// define new sources based on only the new peaks & measure moments
 	// NOTE: new sources are saved on detections->newSources
 	psphotSourceStats (config, view, filerule, false); // pass 2 (detections->newSources)
@@ -312,6 +305,7 @@
 pass1finish:
 
-    // XXX re-measure the kron mags with models subtracted
-    psphotKronMasked(config, view, filerule);
+    // re-measure the kron mags with models subtracted
+    // psphotKronMasked(config, view, filerule);
+    psphotKronIterate(config, view, filerule);
 
     // measure source size for the remaining sources
@@ -321,5 +315,5 @@
     psphotExtendedSourceAnalysis (config, view, filerule); // pass 1 (detections->allSources)
     psphotExtendedSourceFits (config, view, filerule); // pass 1 (detections->allSources)
-    psphotRadialApertures(config, view, filerule);
+    psphotRadialApertures(config, view, filerule, 0);
 
 finish:
@@ -359,4 +353,6 @@
     }
 
+    psLogMsg ("psphot.readout", PS_LOG_WARN, "complete psphot readout : %f sec\n", psTimerMark ("psphotReadout"));
+
     // create the exported-metadata and free local data
     return psphotReadoutCleanup(config, view, filerule);
