Index: trunk/ppStack/src/ppStackReadout.c
===================================================================
--- trunk/ppStack/src/ppStackReadout.c	(revision 13613)
+++ trunk/ppStack/src/ppStackReadout.c	(revision 14275)
@@ -45,5 +45,6 @@
 
         float seeing = psMetadataLookupF32(NULL, inputFile->fpa->analysis, "PPSTACK.SEEING"); // Seeing FWHM
-        float weight = psMetadataLookupF32(NULL, inputFile->fpa->analysis, "PPSTACK.WEIGHT"); // Rel. weight
+        float weighting = psMetadataLookupF32(NULL, inputFile->fpa->analysis,
+                                              "PPSTACK.WEIGHTING"); // Relative weighting
         float scale = psMetadataLookupF32(NULL, inputFile->fpa->analysis, "PPSTACK.SCALE"); // Rel. scale
 
@@ -77,5 +78,8 @@
         totExposure += exposure;        // Total exposure time
         (void)psBinaryOp(ro->image, ro->image, "/", psScalarAlloc(exposure, PS_TYPE_F32));
-        pmStackData *data = pmStackDataAlloc(ro, seeing, weight); // Data to stack
+        if (ro->weight) {
+            (void)psBinaryOp(ro->weight, ro->weight, "/", psScalarAlloc(exposure, PS_TYPE_F32));
+        }
+        pmStackData *data = pmStackDataAlloc(ro, seeing, weighting); // Data to stack
         psArrayAdd(stack, ARRAY_BUFFER, data);
         psFree(data);                   // Drop reference
@@ -100,5 +104,5 @@
     }
 
-#if 1
+#ifdef INSPECTION_FILES
     {
         psFits *fits = psFitsOpen("combined.fits", "w");
@@ -131,5 +135,5 @@
     }
 
-#if 1
+#ifdef REJECTION_FILES
     for (int i = 0; i < num; i++) {
         pmStackData *data = stack->data[i]; // Data for this image
@@ -157,4 +161,7 @@
     // Restore image to counts using the total exposure time
     (void)psBinaryOp(outRO->image, outRO->image, "*", psScalarAlloc(totExposure, PS_TYPE_F32));
+    if (outRO->weight) {
+        (void)psBinaryOp(outRO->weight, outRO->weight, "*", psScalarAlloc(totExposure, PS_TYPE_F32));
+    }
     psMetadataAddF32(outRO->parent->concepts, PS_LIST_TAIL, "CELL.EXPOSURE", PS_META_REPLACE,
                      "Summed exposure time (sec)", totExposure);
