Index: trunk/psphot/src/psphotReadout.c
===================================================================
--- trunk/psphot/src/psphotReadout.c	(revision 6442)
+++ trunk/psphot/src/psphotReadout.c	(revision 6481)
@@ -17,7 +17,9 @@
 
     // construct sources and measure basic stats
+    // limit moments analysis by S/N?
     sources = psphotSourceStats (readout, config, peaks);
 
     // classify sources based on moments, brightness
+    // faint sources not classified?
     psphotRoughClass (sources, config);
 
@@ -28,23 +30,32 @@
     psf = psphotChoosePSF (config, sources);
 
-    // select analysis method
-    char *FITMODE = psMetadataLookupStr (&status, config, "FITMODE");
-    if (!strcasecmp(FITMODE, "ENSEMBLE")) {
-	psphotEnsemblePSF (readout, config, sources, psf);
-    }
+    // linear PSF fit to peaks
+    psphotEnsemblePSF (readout, config, sources, psf, FALSE);
 
-    if (!strcasecmp(FITMODE, "BLEND")) {
-	psphotEnsemblePSF (readout, config, sources, psf);
-	psphotBlendFit (readout, config, sources, psf);
-	psphotReplaceUnfit (sources);
-	psphotApResid (readout, sources, config, psf);
-    }
+    // non-linear PSF and EXT fit to brighter sources
+    psphotBlendFit (readout, config, sources, psf);
 
+    // replace fitted sources
+    psphotReplaceUnfit (sources);
+
+    // find remaining peaks after first source subtraction pass
+    // psphotFindPeaks ();
+
+    // linear PSF fit to remaining peaks
+    psphotEnsemblePSF (readout, config, sources, psf, TRUE);
+
+    // measure aperture photometry corrections
+    psphotApResid (readout, sources, config, psf);
+
+    // calculate source magnitudes
     psphotMagnitudes (config, sources, psf);
 
+    // update the header with stats results
     psMetadata *header = pmReadoutGetHeader (readout);
     psphotUpdateHeader (header, config);
 
-    // psphotSkyReplace (readout, skymodel);
+    // XXX make this an option?
+    // replace background in residual image
+    psphotSkyReplace (readout, skymodel);
 
     // need to do something with the sources, psf, and sky
@@ -66,4 +77,10 @@
 // XXX Deprecate or allow these versions?
 # if (0)
+    // select analysis method
+    char *FITMODE = psMetadataLookupStr (&status, config, "FITMODE");
+    if (!strcasecmp(FITMODE, "ENSEMBLE")) {
+	psphotEnsemblePSF (readout, config, sources, psf);
+    }
+
     if (!strcasecmp(FITMODE, "FULL")) {
 	psphotEnsemblePSF (readout, config, sources, psf);
