Index: branches/cnb_branch_20090215/ppStack/src/ppStack.c
===================================================================
--- branches/cnb_branch_20090215/ppStack/src/ppStack.c	(revision 21495)
+++ branches/cnb_branch_20090215/ppStack/src/ppStack.c	(revision 21536)
@@ -74,5 +74,5 @@
     pmConfigDone();
     psLibFinalize();
-
+    pmVisualClose();
     exit(exitValue);
 }
Index: branches/cnb_branch_20090215/ppStack/src/ppStackArguments.c
===================================================================
--- branches/cnb_branch_20090215/ppStack/src/ppStackArguments.c	(revision 21495)
+++ branches/cnb_branch_20090215/ppStack/src/ppStackArguments.c	(revision 21536)
@@ -176,11 +176,4 @@
     psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-limit", 0, "Limit on star rejection fraction for successful iteration", NAN);
     psMetadataAddF32(arguments, PS_LIST_TAIL, "-zp-star-sys", 0, "Estimated systematic error", NAN);
-    psMetadataAddBool(arguments, PS_LIST_TAIL, "-renorm", 0, "Renormalise variance maps?", false);
-    psMetadataAddStr(arguments, PS_LIST_TAIL, "-renorm-mean", 0,
-                     "Statistic for mean in renormalisation", NULL);
-    psMetadataAddStr(arguments, PS_LIST_TAIL, "-renorm-stdev", 0,
-                     "Statistic for stdev in renormalisation", NULL);
-    psMetadataAddF32(arguments, PS_LIST_TAIL, "-renorm-width", 0, "Gaussian width for renormalisation", NAN);
-    psMetadataAddS32(arguments, PS_LIST_TAIL, "-renorm-num", 0, "Number of samples for renormalisation", 0);
     psMetadataAddStr(arguments, PS_LIST_TAIL, "-temp-image", 0, "Suffix for temporary images", NULL);
     psMetadataAddStr(arguments, PS_LIST_TAIL, "-temp-mask", 0, "Suffix for temporary masks", NULL);
@@ -189,5 +182,5 @@
                       "Delete temporary files on completion?", false);
     psMetadataAddS32(arguments, PS_LIST_TAIL, "-threads", 0, "Number of threads to use", 0);
-    psMetadataAddBool(arguments, PS_LIST_TAIL, "-psphot-visual", 0, "psphot visualisation", 0);
+    psMetadataAddBool(arguments, PS_LIST_TAIL, "-visual", 0, "visualisation", 0);
 
     if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 3) {
@@ -280,13 +273,4 @@
     }
 
-    if (psMetadataLookupBool(NULL, arguments, "-renorm") ||
-        psMetadataLookupBool(NULL, recipe, "RENORM")) {
-        psMetadataAddBool(arguments, PS_LIST_TAIL, "RENORM", 0, "Renormalise variance maps?", true);
-    }
-    VALUE_ARG_RECIPE_INT("-renorm-num", "RENORM.NUM", S32, 0);
-    VALUE_ARG_RECIPE_FLOAT("-renorm-width", "RENORM.WIDTH", F32);
-    valueArgRecipeStr(arguments, recipe, "-renorm-mean",  "RENORM.MEAN", recipe);
-    valueArgRecipeStr(arguments, recipe, "-renorm-stdev", "RENORM.STDEV", recipe);
-
     valueArgRecipeStr(arguments, recipe, "-temp-image",    "TEMP.IMAGE",  recipe);
     valueArgRecipeStr(arguments, recipe, "-temp-mask",     "TEMP.MASK",   recipe);
Index: branches/cnb_branch_20090215/ppStack/src/ppStackLoop.c
===================================================================
--- branches/cnb_branch_20090215/ppStack/src/ppStackLoop.c	(revision 21495)
+++ branches/cnb_branch_20090215/ppStack/src/ppStackLoop.c	(revision 21536)
@@ -480,4 +480,8 @@
             psMetadataAddF32(stats, PS_LIST_TAIL, "STAMP.NUM", PS_META_DUPLICATE_OK,
                              "Number of stamps", kernels->numStamps);
+            float deconv = psMetadataLookupF32(NULL, readout->analysis,
+                                               PM_SUBTRACTION_ANALYSIS_DECONV_MAX); // Deconvolution fraction
+            psMetadataAddF32(stats, PS_LIST_TAIL, "KERNEL.DECONV", PS_META_DUPLICATE_OK,
+                             "Deconvolution fraction for kernel", deconv);
             psMetadataAddF32(stats, PS_LIST_TAIL, "PPSTACK.WEIGHTING", PS_META_DUPLICATE_OK,
                              "Weighting for image", weightings->data.F32[i]);
@@ -503,4 +507,5 @@
             psStringAppend(&name, "covariance_%d.fits", i);
             writeImage(name, hdu->header, readout->covariance->image, config);
+            pmStackVisualPlotTestImage(readout->covariance->image, name);
             psFree(name);
         }
@@ -801,4 +806,5 @@
 #ifdef TESTING
     writeImage("combined_initial.fits", NULL, outRO->image, config);
+    pmStackVisualPlotTestImage(outRO->image, "combined_initial.fits");
 #endif
 
@@ -884,4 +890,5 @@
                 psString name = NULL;           // Name of image
                 psStringAppend(&name, "inspect_%03d.fits", i);
+                pmStackVisualPlotTestImage(mask, name);
                 psFits *fits = psFitsOpen(name, "w");
                 psFree(name);
@@ -901,4 +908,5 @@
                 psString name = NULL;           // Name of image
                 psStringAppend(&name, "reject_%03d.fits", i);
+                pmStackVisualPlotTestImage(mask, name);
                 psFits *fits = psFitsOpen(name, "w");
                 psFree(name);
@@ -1034,4 +1042,5 @@
 
 #ifdef TESTING
+    pmStackVisualPlotTestImage(outRO->image, "combined_initial.fits");
     writeImage("combined_final.fits", NULL, outRO->image, config);
 #endif
@@ -1151,23 +1160,4 @@
     psLogMsg("ppStack", PS_LOG_INFO, "Stage 7 : WCS & JPEGS : %f sec", psTimerClear("PPSTACK_STEPS"));
 
-    if (psMetadataLookupBool(&mdok, recipe, "RENORM")) {
-        // Statistics for renormalisation
-        psStatsOptions renormMean = psStatsOptionFromString(psMetadataLookupStr(&mdok, recipe,
-                                                                                "RENORM.MEAN"));
-        psStatsOptions renormStdev = psStatsOptionFromString(psMetadataLookupStr(&mdok, recipe,
-                                                                                 "RENORM.STDEV"));
-        int renormNum = psMetadataLookupS32(&mdok, recipe, "RENORM.NUM"); // Number of samples
-        float renormWidth = psMetadataLookupS32(&mdok, recipe, "RENORM.WIDTH"); // Width of Gaussian phot
-        psImageMaskType maskValue = pmConfigMaskGet("BLANK", config); // Bits to mask
-        if (!pmReadoutVarianceRenormPhot(outRO, maskValue, renormNum, renormWidth,
-                                         renormMean, renormStdev, NULL)) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to renormalise variances.");
-            psFree(outRO);
-            return false;
-        }
-    }
-
-    psLogMsg("ppStack", PS_LOG_INFO, "Stage 8 : Photometry Renormalization : %f sec", psTimerClear("PPSTACK_STEPS"));
-
     if (psMetadataLookupBool(&mdok, recipe, "PHOTOMETRY")) {
         psTrace("ppStack", 1, "Photometering stacked image....\n");
@@ -1199,5 +1189,5 @@
     }
 
-    psLogMsg("ppStack", PS_LOG_INFO, "Stage 9 : Photometry Analysis : %f sec", psTimerClear("PPSTACK_STEPS"));
+    psLogMsg("ppStack", PS_LOG_INFO, "Stage 8 : Photometry Analysis : %f sec", psTimerClear("PPSTACK_STEPS"));
 
     psThreadPoolFinalize();
@@ -1254,5 +1244,5 @@
     }
 
-    psLogMsg("ppStack", PS_LOG_INFO, "Stage 10 : Final Output : %f sec", psTimerClear("PPSTACK_STEPS"));
+    psLogMsg("ppStack", PS_LOG_INFO, "Stage 9 : Final Output : %f sec", psTimerClear("PPSTACK_STEPS"));
 
     memDump("finish");
Index: branches/cnb_branch_20090215/ppStack/src/ppStackMatch.c
===================================================================
--- branches/cnb_branch_20090215/ppStack/src/ppStackMatch.c	(revision 21495)
+++ branches/cnb_branch_20090215/ppStack/src/ppStackMatch.c	(revision 21536)
@@ -189,5 +189,4 @@
 
     bool mdok;                          // Status of MD lookup
-    bool renorm = psMetadataLookupBool(&mdok, recipe, "RENORM"); // Renormalise variances?
     float penalty = psMetadataLookupF32(NULL, ppsub, "PENALTY"); // Penalty for wideness
     int threads = psMetadataLookupS32(NULL, config->arguments, "-threads"); // Number of threads
@@ -359,4 +358,5 @@
                 psString name = NULL;
                 psStringAppend(&name, "fake_%03d.fits", numInput);
+                pmStackVisualPlotTestImage(fake->image, name);
                 psFits *fits = psFitsOpen(name, "w");
                 psFree(name);
@@ -368,4 +368,5 @@
                 psString name = NULL;
                 psStringAppend(&name, "real_%03d.fits", numInput);
+                pmStackVisualPlotTestImage(readout->image, name);
                 psFits *fits = psFitsOpen(name, "w");
                 psFree(name);
@@ -374,19 +375,4 @@
             }
 #endif
-
-            // Renormalise the variances if desired
-            if (renorm) {
-                // Statistics for renormalisation
-                psStatsOptions renormMean = psStatsOptionFromString(psMetadataLookupStr(&mdok, recipe,
-                                                                                        "RENORM.MEAN"));
-                psStatsOptions renormStdev = psStatsOptionFromString(psMetadataLookupStr(&mdok, recipe,
-                                                                                         "RENORM.STDEV"));
-
-                if (!pmReadoutVarianceRenormPixels(readout, maskBad, renormMean, renormStdev, rng)) {
-                    psError(PS_ERR_UNKNOWN, false, "Unable to renormalise variances.");
-                    psFree(output);
-                    return false;
-                }
-            }
 
             if (threads > 0) {
@@ -413,4 +399,5 @@
                 psString name = NULL;
                 psStringAppend(&name, "conv_%03d.fits", numInput);
+                pmStackVisualPlotTestImage(output->image, name);
                 psFits *fits = psFitsOpen(name, "w");
                 psFree(name);
@@ -422,4 +409,5 @@
                 psString name = NULL;
                 psStringAppend(&name, "diff_%03d.fits", numInput);
+                pmStackVisualPlotTestImage(fake->image, name);
                 psFits *fits = psFitsOpen(name, "w");
                 psFree(name);
@@ -562,19 +550,4 @@
     }
 
-    // Renormalise the variances if desired
-    if (renorm) {
-        // Statistics for renormalisation
-        psStatsOptions renormMean = psStatsOptionFromString(psMetadataLookupStr(&mdok, recipe,
-                                                                                "RENORM.MEAN"));
-        psStatsOptions renormStdev = psStatsOptionFromString(psMetadataLookupStr(&mdok, recipe,
-                                                                                 "RENORM.STDEV"));
-
-        if (!pmReadoutVarianceRenormPixels(readout, maskBad, renormMean, renormStdev, rng)) {
-            psError(PS_ERR_UNKNOWN, false, "Unable to renormalise variances.");
-            psFree(output);
-            return false;
-        }
-    }
-
     // Ensure the background value is zero
     psStats *bg = psStatsAlloc(PS_STAT_ROBUST_MEDIAN | PS_STAT_ROBUST_STDEV); // Statistics for background
@@ -664,4 +637,5 @@
         psString name = NULL;
         psStringAppend(&name, "convolved_%03d.fits", numInput);
+        pmStackVisualPlotTestImage(output->image, name);
         psFits *fits = psFitsOpen(name, "w");
         psFree(name);
Index: branches/cnb_branch_20090215/ppStack/src/ppStackPhotometry.c
===================================================================
--- branches/cnb_branch_20090215/ppStack/src/ppStackPhotometry.c	(revision 21495)
+++ branches/cnb_branch_20090215/ppStack/src/ppStackPhotometry.c	(revision 21536)
@@ -118,6 +118,6 @@
     pmFPACopy(photFile->fpa, readout->parent->parent->parent);
 
-    if (psMetadataLookupBool(NULL, config->arguments, "-psphot-visual")) {
-        psphotSetVisual(true);
+    if (psMetadataLookupBool(NULL, config->arguments, "-visual")) {
+        pmVisualSetVisual(true);
     }
 
Index: branches/cnb_branch_20090215/ppStack/src/ppStackSources.c
===================================================================
--- branches/cnb_branch_20090215/ppStack/src/ppStackSources.c	(revision 21495)
+++ branches/cnb_branch_20090215/ppStack/src/ppStackSources.c	(revision 21536)
@@ -69,4 +69,5 @@
         psString name = NULL;
         psStringAppend(&name, "start_%03d.fits", i);
+        pmStackVisualPlotTestImage(fake->image, name);
         psFits *fits = psFitsOpen(name, "w");
         psFree(name);
@@ -154,15 +155,15 @@
     int minMatches = PS_MAX (2, 0.5*num);
     for (int i = 0; i < matches->n; i++) {
-	pmSourceMatch *match = matches->data[i]; // Match of interest
-	if (match->num < minMatches) continue;
-
-	// We need to grab a single instance of this source: just take the first available
-	int nImage = match->image->data.S32[0];
-	int nIndex = match->index->data.S32[0];
-	psArray *sources = sourceLists->data[nImage];
-	pmSource *source = sources->data[nIndex];
-	
-	// stick this sample source on sourcesBest
-	psArrayAdd (sourcesBest, 100, source);
+        pmSourceMatch *match = matches->data[i]; // Match of interest
+        if (match->num < minMatches) continue;
+
+        // We need to grab a single instance of this source: just take the first available
+        int nImage = match->image->data.S32[0];
+        int nIndex = match->index->data.S32[0];
+        psArray *sources = sourceLists->data[nImage];
+        pmSource *source = sources->data[nIndex];
+
+        // stick this sample source on sourcesBest
+        psArrayAdd (sourcesBest, 100, source);
     }
     psMetadataAdd (sourcesCell->analysis, PS_LIST_TAIL, "PSPHOT.SOURCES", PS_DATA_ARRAY | PS_META_REPLACE, "psphot sources", sourcesBest);
