Index: trunk/psphot/src/psphot.c
===================================================================
--- trunk/psphot/src/psphot.c	(revision 4114)
+++ trunk/psphot/src/psphot.c	(revision 4115)
@@ -24,5 +24,9 @@
     peaks = find_peaks (image, config, sky);
 
+    // construct sources and measure basic stats
     sources = source_moments (image, config, peaks);
+
+    // source analysis is done in S/N order (brightest first)
+    sources = psArraySort (sources, by_SN);
 
     // use stellar objects SN > PSF_SN_LIM
@@ -35,12 +39,4 @@
     // XXX it has some problems
     // test_psf_scatter (sources);
-
-    // identify PSF-like objects (< PSF_SHAPE_NSIGMA from dSx,dSy model)
-    // SN <= FAINT_SN_LIM : FAINTSTAR
-    // SN >  FAINT_SN_LIM : BRIGHTSTAR
-    mark_psf_sources (sources, config);
-
-    // subtract BRIGHTSTAR, PSFSTAR, SATSTAR
-    subtract_psf_sources (sources);
 
     // fit_galaxies (image, config, sources);
