Index: /branches/eam_branches/20091201/psModules/src/imcombine/pmPSFEnvelope.c
===================================================================
--- /branches/eam_branches/20091201/psModules/src/imcombine/pmPSFEnvelope.c	(revision 26593)
+++ /branches/eam_branches/20091201/psModules/src/imcombine/pmPSFEnvelope.c	(revision 26594)
@@ -65,5 +65,6 @@
                      int radius,        // Radius of each PSF
                      const char *modelName,// Name of PSF model to use
-                     int xOrder, int yOrder // Order for PSF variation fit
+                     int xOrder, int yOrder, // Order for PSF variation fit
+		     psImageMaskType maskVal
                      )
 {
@@ -360,5 +361,6 @@
 
         // measure the source moments: tophat windowing, no pixel S/N cutoff
-        if (!pmSourceMoments(source, maxRadius, 0.0, 1.0)) {
+	// XXX probably should be passing the maskVal to this function so we can pass it along here...
+        if (!pmSourceMoments(source, maxRadius, 0.0, 1.0, maskVal)) {
             // Can't do anything about it; limp along as best we can
             psErrorClear();
Index: /branches/eam_branches/20091201/psModules/src/imcombine/pmPSFEnvelope.h
===================================================================
--- /branches/eam_branches/20091201/psModules/src/imcombine/pmPSFEnvelope.h	(revision 26593)
+++ /branches/eam_branches/20091201/psModules/src/imcombine/pmPSFEnvelope.h	(revision 26594)
@@ -17,5 +17,6 @@
                      int radius,        // Radius of each PSF
                      const char *modelName, // Name of PSF model to use
-                     int xOrder, int yOrder // Order for PSF variation
+                     int xOrder, int yOrder, // Order for PSF variation
+		     psImageMaskType maskVal
     );
 
Index: /branches/eam_branches/20091201/psModules/src/objects/pmPeaks.c
===================================================================
--- /branches/eam_branches/20091201/psModules/src/objects/pmPeaks.c	(revision 26593)
+++ /branches/eam_branches/20091201/psModules/src/objects/pmPeaks.c	(revision 26594)
@@ -375,5 +375,5 @@
     psU32 col = 0;
     psU32 row = 0;
-    psArray *list = NULL;
+    psArray *list = psArrayAllocEmpty(100);
 
     // Find peaks in row 0 only.
@@ -416,5 +416,5 @@
 
         } else {
-            psError(PS_ERR_UNKNOWN, true, "peak specified valid column range.");
+            psLogMsg ("psModules.objects", 5, "peak specified outside valid column range.");
         }
     }
@@ -501,5 +501,5 @@
                 }
             } else {
-                psError(PS_ERR_UNKNOWN, true, "peak specified outside valid column range.");
+		psLogMsg ("psModules.objects", 5, "peak specified outside valid column range.");
             }
 
@@ -545,5 +545,5 @@
             }
         } else {
-            psError(PS_ERR_UNKNOWN, true, "peak specified outside valid column range.");
+            psLogMsg ("psModules.objects", 5, "peak specified outside valid column range.");
         }
     }
Index: /branches/eam_branches/20091201/psModules/src/objects/pmSource.c
===================================================================
--- /branches/eam_branches/20091201/psModules/src/objects/pmSource.c	(revision 26593)
+++ /branches/eam_branches/20091201/psModules/src/objects/pmSource.c	(revision 26594)
@@ -409,5 +409,10 @@
 
         // if we failed to find a valid peak, return the empty clump (failure signal)
-        if (peaks == NULL)
+	if (peaks == NULL) {
+            psError(PS_ERR_UNKNOWN, false, "failure in peak analysis for PSF clump.\n");
+            return emptyClump;
+	}
+
+        if (peaks->n == 0)
         {
             psLogMsg ("psphot", 3, "failed to find a peak in the PSF clump image\n");
Index: /branches/eam_branches/20091201/psModules/src/objects/pmSource.h
===================================================================
--- /branches/eam_branches/20091201/psModules/src/objects/pmSource.h	(revision 26593)
+++ /branches/eam_branches/20091201/psModules/src/objects/pmSource.h	(revision 26594)
@@ -220,5 +220,6 @@
     float radius,     ///< Use a circle of pixels around the peak
     float sigma,      ///< size of Gaussian window function (<= 0.0 -> skip window)
-    float minSN	      ///< minimum pixel significance
+    float minSN,	      ///< minimum pixel significance
+    psImageMaskType maskVal
 );
 
Index: /branches/eam_branches/20091201/psModules/src/objects/pmSourceMoments.c
===================================================================
--- /branches/eam_branches/20091201/psModules/src/objects/pmSourceMoments.c	(revision 26593)
+++ /branches/eam_branches/20091201/psModules/src/objects/pmSourceMoments.c	(revision 26594)
@@ -54,5 +54,5 @@
 # define VALID_RADIUS(X,Y,RAD2) (((RAD2) >= (PS_SQR(X) + PS_SQR(Y))) ? 1 : 0)
 
-bool pmSourceMoments(pmSource *source, psF32 radius, psF32 sigma, psF32 minSN)
+bool pmSourceMoments(pmSource *source, psF32 radius, psF32 sigma, psF32 minSN, psImageMaskType maskVal)
 {
     PS_ASSERT_PTR_NON_NULL(source, false);
@@ -114,5 +114,5 @@
         for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) {
             if (vMsk) {
-                if (*vMsk) {
+                if (*vMsk & maskVal) {
                     vMsk++;
                     continue;
@@ -226,5 +226,5 @@
 	for (psS32 col = 0; col < source->pixels->numCols ; col++, vPix++, vWgt++) {
 	    if (vMsk) {
-		if (*vMsk) {
+		if (*vMsk & maskVal) {
 		    vMsk++;
 		    continue;
