Index: branches/eam_branches/ipp-20120627/psModules/src/config/pmConfig.c
===================================================================
--- branches/eam_branches/ipp-20120627/psModules/src/config/pmConfig.c	(revision 34245)
+++ branches/eam_branches/ipp-20120627/psModules/src/config/pmConfig.c	(revision 34246)
@@ -685,5 +685,5 @@
             } else {
                 char *end = NULL;       // Pointer to end of consumed string
-                seed = strtoll(argv[argNum], &end, 0);
+                seed = strtoull(argv[argNum], &end, 0);
                 if (strlen(end) > 0) {
                     psError(PM_ERR_CONFIG, true, "Unable to read random number generator seed: %s",
Index: branches/eam_branches/ipp-20120627/psModules/src/imcombine/pmStack.c
===================================================================
--- branches/eam_branches/ipp-20120627/psModules/src/imcombine/pmStack.c	(revision 34245)
+++ branches/eam_branches/ipp-20120627/psModules/src/imcombine/pmStack.c	(revision 34246)
@@ -357,5 +357,6 @@
         sumWeight += weights->data.F32[i];
         if (variances) {
-            sumVarianceWeight += variances->data.F32[i] * PS_SQR(weights->data.F32[i]);
+	  //            sumVarianceWeight += variances->data.F32[i] * PS_SQR(weights->data.F32[i]);
+	  sumVarianceWeight += 1 / variances->data.F32[i];
         }
         if (exps) {
@@ -372,5 +373,6 @@
     *mean = sumValueWeight / sumWeight;
     if (var) {
-        *var = sumVarianceWeight / PS_SQR(sumWeight);
+      //*var = sumVarianceWeight / PS_SQR(sumWeight);
+      *var = 1 / sumVarianceWeight;
     }
     if (exp) {
Index: branches/eam_branches/ipp-20120627/psModules/src/objects/pmFootprintCullPeaks.c
===================================================================
--- branches/eam_branches/ipp-20120627/psModules/src/objects/pmFootprintCullPeaks.c	(revision 34245)
+++ branches/eam_branches/ipp-20120627/psModules/src/objects/pmFootprintCullPeaks.c	(revision 34246)
@@ -118,8 +118,10 @@
 	    threshbounds->data.F32[i] = 0.25*beta2*PS_SQR(i) + min_threshold;	    
 	}
+#if (0)
         if (threshbounds->data.F32[threshbounds->n-1] > maxFlux) {
             psWarning ("upper limit: %f does not include max flux: %f",
                     threshbounds->data.F32[threshbounds->n-1], maxFlux);
         }
+#endif
 	psHistogram *threshist = psHistogramAllocGeneric(threshbounds);
 
@@ -195,5 +197,5 @@
 	    psImageInit(idImg, 0);
 	    pmSetFootprintArrayIDsForImage(idImg, myFP, true);
-	
+
 	    // check which footprints contain already-accepted (brighter) peaks 
 	    // (we can give up if/when we found a peak for all footprints)
Index: branches/eam_branches/ipp-20120627/psModules/src/objects/pmFootprintFind.c
===================================================================
--- branches/eam_branches/ipp-20120627/psModules/src/objects/pmFootprintFind.c	(revision 34245)
+++ branches/eam_branches/ipp-20120627/psModules/src/objects/pmFootprintFind.c	(revision 34246)
@@ -24,4 +24,5 @@
 
 // XXX EAM : why use WSPAN in here rather than pmSpan?
+// XXX WES : can't use pmSpan because does not have an id
 typedef struct {                        /* run-length code for part of object*/
    int id;                              /* ID for object */
@@ -114,7 +115,10 @@
 
        in_span = 0;                      /* not in a span */
+       int id_last_connection = 0;
        for (j = 0; j < numCols; j++) {
            double pixVal = floatImg->data.F32[i][j]; // Value of pixel
+           // If pixVal is less than threshold and we are working on a, span end it.
            if (pixVal < threshold) {
+               // below threshold. If in a span close it out
                if (in_span) {
                    if(nspan >= size_spans) {
@@ -130,6 +134,19 @@
 
                    in_span = 0;
+                   id_last_connection = 0;
                }
            } else {                       /* a pixel to fix */
+               // Above theshold. There are 5 choices for the id of this pixel based on whether they are
+               // part of a span (non-zero)
+               // This diagram shows the priority which we check
+               //       
+               //                       col
+               //                   j-1   j   j+1
+               // row i              1    5 
+               // row i + 1          2    3    4
+               //
+               // In case 4 we have a pixel that is not connected to the left are connecting with 
+               // an existing span so need to identify whether it is connected
+               // to the same footprint as the current span (if we are in one)
                if(idc[j - 1] != 0) {
                    id = idc[j - 1];
@@ -157,9 +174,20 @@
                 * Do we need to merge ID numbers? If so, make suitable entries in aliases[]
                 */
-               if(idp[j + 1] != 0 && idp[j + 1] != id) {
-                   aliases[resolve_alias(aliases, idp[j + 1])] =
-                       resolve_alias(aliases, id);
-
-                   idc[j] = id = idp[j + 1];
+               if (idp[j + 1] != 0 && idp[j + 1] != id && idp[j + 1] != id_last_connection) {
+                   int resolved_lower_right = resolve_alias(aliases, idp[j + 1]);
+                   int resolved_current = resolve_alias(aliases, id);
+                   aliases[resolved_lower_right] = resolved_current;
+
+                   // now we choose the id to continue to use to set pixels in the current span.
+                   // We choose the higher value because future alias resolutions will be faster
+                   // since the alias chain goes from lower ids to higher. This is about 4 times
+                   // faster for complex footprints.
+                   if (resolved_current <= idp[j + 1]) {
+                       idc[j] = id = idp[j + 1];
+                       id_last_connection = 0;
+                   } else {
+                       idc[j] = id = resolved_current;
+                       id_last_connection = idp[j + 1];
+                   }
                }
            }
Index: branches/eam_branches/ipp-20120627/psModules/src/objects/pmPSFtryMakePSF.c
===================================================================
--- branches/eam_branches/ipp-20120627/psModules/src/objects/pmPSFtryMakePSF.c	(revision 34245)
+++ branches/eam_branches/ipp-20120627/psModules/src/objects/pmPSFtryMakePSF.c	(revision 34246)
@@ -138,7 +138,5 @@
 	}
 	if (trend->mode == PM_TREND_MAP) {
-	    // p_psImagePrint (2, trend->map->map, "param N Before"); // XXX TEST:
 	    psImageMapRepair (trend->map->map);
-	    // p_psImagePrint (2, trend->map->map, "param N After"); // XXX TEST:
 	}
     }
@@ -246,4 +244,7 @@
 	    return true;
 	}
+	if (trend->mode == PM_TREND_MAP) {
+	    psImageMapRepair (trend->map->map);
+	}
 
 # if (PS_TRACE_ON)
@@ -268,4 +269,8 @@
 	    return true;
 	}
+	if (trend->mode == PM_TREND_MAP) {
+	    psImageMapRepair (trend->map->map);
+	}
+
 # if (PS_TRACE_ON)
 	mean = psStatsGetValue (trend->stats, meanOption);
@@ -285,4 +290,8 @@
 	    return true;
 	}
+	if (trend->mode == PM_TREND_MAP) {
+	    psImageMapRepair (trend->map->map);
+	}
+
 # if (PS_TRACE_ON)
 	mean = psStatsGetValue (trend->stats, meanOption);
