Index: /trunk/psphot/src/psphotBasicDeblend.c
===================================================================
--- /trunk/psphot/src/psphotBasicDeblend.c	(revision 11163)
+++ /trunk/psphot/src/psphotBasicDeblend.c	(revision 11164)
@@ -27,5 +27,5 @@
     for (int i = 0; i < SN->n; i++) {
         source = sources->data[i];
-        SN->data.F32[i] = source->peak->counts;
+        SN->data.F32[i] = source->peak->SN;
     }
     psVector *index = psVectorSortIndex (NULL, SN);
@@ -79,7 +79,7 @@
         // threshold is fraction of the source peak flux
         // image is background subtracted; source->moments->Sky should always be 0.0
-        threshold = FRACTION * source->moments->Peak;
-        // threshold is no less than NSIGMA above the local median sigma?
-        threshold = PS_MAX (threshold, NSIGMA*sqrt(source->moments->dSky));
+        threshold = FRACTION * source->peak->SN;
+        // threshold is no less than NSIGMA
+        threshold = PS_MAX (threshold, NSIGMA);
 
         // generate a basic contour (set of x,y coordinates at-or-below flux level)
@@ -95,9 +95,12 @@
         // the left boundary and xv[i+1] corresponding to the right boundary
 
+	// a blend can only be associated with one primary source
+
         psVector *xv = contour->data[0];
         psVector *yv = contour->data[1];
         for (int k = 0; k < overlap->n; k++) {
             testSource = overlap->data[k];
-            if (testSource->peak->counts > source->peak->counts) continue;
+	    if (testSource->mode & PM_SOURCE_MODE_BLEND) continue;
+            if (testSource->peak->value > source->peak->value) continue;
             for (int j = 0; j < xv->n; j+=2) {
                 if (fabs(yv->data.F32[j] - testSource->peak->y) > 0.5) continue;
