Index: trunk/psphot/src/psphotStackUpdateReadout.c
===================================================================
--- trunk/psphot/src/psphotStackUpdateReadout.c	(revision 38396)
+++ trunk/psphot/src/psphotStackUpdateReadout.c	(revision 38515)
@@ -116,5 +116,7 @@
     // XXX NOTE : if we use the pre-20130914 psphotStackReadout code, we need to use 'false' for the
     // sourcesSubtracted argument
-    psArray *objectsOut = psphotSourceChildrenByObject (config, view, STACK_OUT, objects, true);
+    // XXX: do this here so that the variance is availble to rebuild the models
+    psphotStackMatchPSFsetup (config, view, STACK_OUT, STACK_RAW);
+    psArray *objectsOut = psphotSourceChildrenByObject (config, view, STACK_OUT, STACK_RAW, objects, true);
     if (!objectsOut) {
 	psFree(objects);
@@ -135,6 +137,6 @@
         // this forces photometry on the undetected sources from other images
 
-	// set up the FWHM vector
-	psphotStackMatchPSFsetup (config, view, STACK_OUT, STACK_RAW);
+//	Moved this up above
+//	psphotStackMatchPSFsetup (config, view, STACK_OUT, STACK_RAW);
 	psphotDumpImages (config, view, STACK_RAW, "raw.t0");
 	psphotDumpImages (config, view, STACK_OUT, "out.t0");
@@ -177,4 +179,9 @@
 		// and to subtract the sources
 		psphotFitSourcesLinear (config, view, STACK_OUT, false, false);
+
+#ifdef notyet
+            psphotRemoveAllSources (config, view, STACK_OUT, false);
+#endif
+
 		snprintf (line, 256, "%s.%d", "out.t4", entry);
 		psphotDumpImages (config, view, STACK_OUT, line);
@@ -221,5 +228,5 @@
         COPY_PARAM( "MSKY_NX" );
         COPY_PARAM( "MSKY_NY" );
-        COPY_PARAM( "CHIP_SEEING" );
+        // COPY_PARAM( "CHIP_SEEING" );
 }
 
@@ -312,6 +319,10 @@
     fitOptions->poissonErrors = psMetadataLookupBool (&status, recipe, "EXTENDED_SOURCE_FITS_POISSON");
     if (!status) fitOptions->poissonErrors = true;
+
     int psfSize  = psMetadataLookupS32 (&status, recipe, "PCM_BOX_SIZE");
     assert (status);
+    
+    // Remember these data for later
+    psMetadataAddPtr (readout->analysis, PS_LIST_TAIL, "PCM_FIT_OPTIONS", PS_DATA_UNKNOWN | PS_META_REPLACE, "pcm fit options", fitOptions);
 
     for (int i = 0; i < sources->n; i++) {
@@ -331,11 +342,12 @@
             // fprintf(stderr, "source %d %5d should not have a psf model 0x%08X%08X\n", index, source->seq, source->mode2, source->mode);
             psFree(source->modelPSF) ;
+            modelPSF = NULL;
         }
 
         // make sure that the window radius is large enough. Should we do this regardless of whether
         // or not the source is extended?
-        if (source->modelEXT) {
-            float fitRadius = NAN;
-            float windowRadius = NAN;
+        float fitRadius = NAN;
+        float windowRadius = NAN;
+        if (1 || source->modelEXT) {
             if (!psphotSetRadiusMoments (&fitRadius, &windowRadius, readout, source, markVal)) {
                 psError (PSPHOT_ERR_UNKNOWN, false, "failed to set radius for ext source");
@@ -387,5 +399,8 @@
                 float modelFlux = pow(10., -0.4 * model->mag);
 
-                // XXX: We are assuming here that we only use PCM models. Should get that information from the recipe.
+                model->fitRadius = fitRadius;
+
+                // XXX: We are assuming here that we only use PCM models. 
+                // I Should be getting that information from the recipe.
                 pmPCMdata *pcm = pmPCMinit (source, fitOptions, model, maskVal, psfSize);
                 if (!pcm) {
@@ -394,5 +409,6 @@
                 }
                 model->params->data.F32[PM_PAR_I0] = 1.0;
-                pmPCMMakeModel (source, model, pcm->nsigma, maskVal, psfSize);
+                // XXX: this duplicates work that pmPCMCacheModel does
+                // pmPCMMakeModel (source, model, pcm->nsigma, maskVal, psfSize);
                 float normFlux = model->class->modelFlux(model->params);
                 float I0 = modelFlux / normFlux;
