Index: trunk/psModules/src/objects/pmSource.c
===================================================================
--- trunk/psModules/src/objects/pmSource.c	(revision 31153)
+++ trunk/psModules/src/objects/pmSource.c	(revision 31451)
@@ -116,5 +116,4 @@
     source->psfImage = NULL;
     source->moments = NULL;
-    source->blends = NULL;
     source->modelPSF = NULL;
     source->modelEXT = NULL;
@@ -124,18 +123,11 @@
     source->mode2 = PM_SOURCE_MODE_DEFAULT;
     source->tmpFlags = 0;
-    source->extpars = NULL;
-    source->diffStats = NULL;
-    source->radialAper = NULL;
-    source->parent = NULL;
-
-    source->region = psRegionSet(NAN, NAN, NAN, NAN);
-    psMemSetDeallocator(source, (psFreeFunc) sourceFree);
 
     // default values are NAN
     source->psfMag     	     = NAN;
+    source->psfMagErr 	     = NAN;
     source->psfFlux    	     = NAN;
     source->psfFluxErr 	     = NAN;
     source->extMag 	     = NAN;    
-    source->errMag 	     = NAN;
     source->apMag  	     = NAN;
     source->apMagRaw  	     = NAN;
@@ -143,6 +135,5 @@
     source->apFlux    	     = NAN;
     source->apFluxErr 	     = NAN; 
-    source->sky    	     = NAN;
-    source->skyErr 	     = NAN;    
+
     source->pixWeightNotBad  = NAN;
     source->pixWeightNotPoor = NAN;
@@ -151,4 +142,16 @@
     source->crNsigma         = NAN;
     source->extNsigma        = NAN;
+    source->sky    	     = NAN;
+    source->skyErr 	     = NAN;    
+
+    source->region = psRegionSet(NAN, NAN, NAN, NAN);
+    source->blends = NULL;
+    source->extpars = NULL;
+    source->diffStats = NULL;
+    source->radialAper = NULL;
+    source->parent = NULL;
+    source->imageID = -1;
+
+    psMemSetDeallocator(source, (psFreeFunc) sourceFree);
 
     psTrace("psModules.objects", 10, "---- end ----\n");
@@ -172,11 +175,5 @@
     if (in->peak != NULL) {
         source->peak = pmPeakAlloc (in->peak->x, in->peak->y, in->peak->detValue, in->peak->type);
-        source->peak->xf = in->peak->xf;
-        source->peak->yf = in->peak->yf;
-        source->peak->rawFlux         = in->peak->rawFlux;
-        source->peak->rawFluxStdev    = in->peak->rawFluxStdev;
-        source->peak->smoothFlux      = in->peak->smoothFlux;
-        source->peak->smoothFluxStdev = in->peak->smoothFluxStdev;
-        // source->peak->SN = in->peak->SN;
+	pmPeakCopy(source->peak, in->peak);
     }
 
@@ -195,9 +192,31 @@
 
     // the maskObj is a unique mask array; create a new mask image
-    source->maskObj = in->maskObj ? psImageCopy (NULL, in->maskObj, PS_TYPE_IMAGE_MASK) : NULL;
-
-    source->type = in->type;
-    source->mode = in->mode;
-    source->imageID = in->imageID;
+    source->maskObj = in->maskObj   ? psImageCopy (NULL, in->maskObj, PS_TYPE_IMAGE_MASK) : NULL;
+
+    // NOTE : because of the const id element, we cannot just assign *source = *in
+
+    source->type     	     = in->type;
+    source->mode     	     = in->mode;
+    source->mode2    	     = in->mode2;
+    source->tmpFlags 	     = in->tmpFlags;
+    source->psfMag     	     = in->psfMag;
+    source->psfMagErr 	     = in->psfMagErr;
+    source->psfFlux    	     = in->psfFlux;
+    source->psfFluxErr 	     = in->psfFluxErr;
+    source->extMag 	     = in->extMag;
+    source->apMag  	     = in->apMag;
+    source->apMagRaw  	     = in->apMagRaw;
+    source->apRadius  	     = in->apRadius;
+    source->apFlux    	     = in->apFlux;
+    source->apFluxErr 	     = in->apFluxErr;
+    source->pixWeightNotBad  = in->pixWeightNotBad;
+    source->pixWeightNotPoor = in->pixWeightNotPoor;
+    source->psfChisq         = in->psfChisq;
+    source->crNsigma         = in->crNsigma;
+    source->extNsigma        = in->extNsigma;
+    source->sky    	     = in->sky;
+    source->skyErr 	     = in->skyErr;
+
+    source->region           = in->region;
 
     return(source);
@@ -266,4 +285,16 @@
     extend |= (mySource->maskObj == NULL);
     extend |= (mySource->maskView == NULL);
+
+    // if ((fabs(x - 2020) < 5) && (fabs(y - 366) < 5)) {
+    // 	if (extend) {
+    // 	    fprintf (stderr, "extend T, %f, %f : %f, %f vs %f, %f : %f, %f\n", 
+    // 		     newRegion.x0, newRegion.y0, newRegion.x1, newRegion.y1, 
+    // 		     mySource->region.x0, mySource->region.y0, mySource->region.x1, mySource->region.y1);
+    // 	} else {
+    // 	    fprintf (stderr, "extend F, %f, %f : %f, %f vs %f, %f : %f, %f\n", 
+    // 		     newRegion.x0, newRegion.y0, newRegion.x1, newRegion.y1, 
+    // 		     mySource->region.x0, mySource->region.y0, mySource->region.x1, mySource->region.y1);
+    // 	}
+    // }
 
     if (extend) {
@@ -486,5 +517,5 @@
         // create vectors with Sx, Sy values in window
         // clip sources based on S/N
-        for (psS32 i = 0 ; i < sources->n ; i++)
+        for (psS32 i = 0; i < sources->n; i++)
         {
             pmSource *tmpSrc = (pmSource *) sources->data[i];
@@ -1175,5 +1206,5 @@
     if (!source->moments) return false;		 // can't if there are no moments
     if (!source->moments->nPixels) return false; // can't if the moments were not measured
-    if (source->mode && PM_SOURCE_MODE_MOMENTS_FAILURE) return false; // can't if the moments failed...
+    if (source->mode & PM_SOURCE_MODE_MOMENTS_FAILURE) return false; // can't if the moments failed...
 
     if (source->mode & PM_SOURCE_MODE_SATSTAR) return true; // moments are best for SATSTARs
