Index: trunk/psphot/src/psphotSourceStats.c
===================================================================
--- trunk/psphot/src/psphotSourceStats.c	(revision 16820)
+++ trunk/psphot/src/psphotSourceStats.c	(revision 17396)
@@ -37,11 +37,15 @@
     for (int i = 0; i < peaks->n; i++) {
 
+	pmPeak *peak = peaks->data[i];
+	if (peak->assigned) continue;
+
         // create a new source, add peak
         pmSource *source = pmSourceAlloc();
-        source->peak = (pmPeak *)psMemIncrRefCounter(peaks->data[i]);
+        source->peak = psMemIncrRefCounter(peak);
 
         // allocate image, weight, mask arrays for each peak (square of radius OUTER)
         pmSourceDefinePixels (source, readout, source->peak->x, source->peak->y, OUTER);
         if (!strcasecmp (breakPt, "PEAKS")) {
+	    peak->assigned = true;
             psArrayAdd (sources, 100, source);
             psFree (source);
@@ -49,6 +53,7 @@
         }
 
-        // skip faint sources
+        // skip faint sources for moments measurement
         if (source->peak->SN < MIN_SN) {
+	    peak->assigned = true;
             psArrayAdd (sources, 100, source);
             psFree (source);
@@ -57,5 +62,5 @@
 
         // measure a local sky value
-        // XXX EAM : this should use ROBUST not SAMPLE median, but it is broken
+	// the local sky is now ignored; kept here for reference only
         status = pmSourceLocalSky (source, PS_STAT_SAMPLE_MEDIAN, INNER, maskVal, mark);
         if (!status) {
@@ -80,4 +85,5 @@
         if (status) {
             // add to the source array
+	    peak->assigned = true;
             psArrayAdd (sources, 100, source);
             psFree (source);
@@ -93,4 +99,5 @@
         if (status) {
             // add to the source array
+	    peak->assigned = true;
             psArrayAdd (sources, 100, source);
             psFree (source);
