Index: trunk/ppStack/src/ppStack.h
===================================================================
--- trunk/ppStack/src/ppStack.h	(revision 27400)
+++ trunk/ppStack/src/ppStack.h	(revision 27402)
@@ -69,5 +69,4 @@
                                const psVector *mask, // Mask for input readouts
                                const psVector *weightings, // Weighting factors for each image
-                               const psVector *exposures,  // Exposure time for each image
                                const psVector *addVariance // Additional variance for rejection
     );
@@ -84,10 +83,8 @@
 bool ppStackReadoutFinal(const pmConfig *config,   // Configuration
                          pmReadout *outRO,   // Output readout
-                         pmReadout *expRO,   // Exposure readout
                          const psArray *readouts, // Input readouts
                          const psVector *mask, // Mask for input readouts
                          const psArray *rejected, // Array with pixels rejected in each image
                          const psVector *weightings, // Weighting factors for each image
-                         const psVector *exposures,  // Exposure times for each image
                          const psVector *addVariance, // Additional variance for rejection
                          bool safety,                 // Enable safety switch?
Index: trunk/ppStack/src/ppStackCamera.c
===================================================================
--- trunk/ppStack/src/ppStackCamera.c	(revision 27400)
+++ trunk/ppStack/src/ppStackCamera.c	(revision 27402)
@@ -283,42 +283,4 @@
     }
 
-
-    // Exposure image
-    pmFPA *expFPA = pmFPAConstruct(config->camera, config->cameraName); // FPA to contain the output
-    if (!expFPA) {
-        psError(psErrorCodeLast(), false, "Unable to construct an FPA from camera configuration.");
-        return false;
-    }
-    pmFPAfile *exp = pmFPAfileDefineOutput(config, expFPA, "PPSTACK.OUTPUT.EXP");
-    psFree(expFPA);                        // Drop reference
-    if (!exp) {
-        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.EXP"));
-        return false;
-    }
-    if (exp->type != PM_FPA_FILE_IMAGE) {
-        psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.EXP is not of type IMAGE");
-        return false;
-    }
-    exp->save = true;
-
-    if (!pmFPAAddSourceFromFormat(expFPA, "Stack", exp->format)) {
-        psError(psErrorCodeLast(), false, "Unable to generate output FPA.");
-        return false;
-    }
-
-    // Exposure numbers
-    pmFPAfile *expNum = pmFPAfileDefineOutput(config, exp->fpa, "PPSTACK.OUTPUT.EXPNUM");
-    if (!expNum) {
-        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.OUTPUT.MASK"));
-        return false;
-    }
-    if (expNum->type != PM_FPA_FILE_MASK) {
-        psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.OUTPUT.EXPNUM is not of type MASK");
-        return false;
-    }
-    expNum->save = true;
-
-
-
     if (havePSFs) {
         pmFPA *psfFPA = pmFPAConstruct(config->camera, config->cameraName); // FPA to contain PSF
@@ -340,4 +302,5 @@
     }
 
+#if 1
     // Unconvolved stack
     pmFPA *unconvFPA = pmFPAConstruct(config->camera, config->cameraName); // FPA to contain unconvolved output
@@ -388,41 +351,5 @@
         unconvVariance->save = true;
     }
-
-
-    // Exposure image
-    pmFPA *unconvExpFPA = pmFPAConstruct(config->camera, config->cameraName); // FPA to contain the output
-    if (!unconvExpFPA) {
-        psError(psErrorCodeLast(), false, "Unable to construct an FPA from camera configuration.");
-        return false;
-    }
-    pmFPAfile *unconvExp = pmFPAfileDefineOutput(config, unconvExpFPA, "PPSTACK.UNCONV.EXP");
-    psFree(unconvExpFPA);               // Drop reference
-    if (!unconvExp) {
-        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.UNCONV.EXP"));
-        return false;
-    }
-    if (unconvExp->type != PM_FPA_FILE_IMAGE) {
-        psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.UNCONV.EXP is not of type IMAGE");
-        return false;
-    }
-    unconvExp->save = true;
-
-    if (!pmFPAAddSourceFromFormat(unconvExpFPA, "Stack", unconvExp->format)) {
-        psError(psErrorCodeLast(), false, "Unable to generate output FPA.");
-        return false;
-    }
-
-    // Output mask
-    pmFPAfile *unconvExpNum = pmFPAfileDefineOutput(config, unconvExp->fpa, "PPSTACK.UNCONV.EXPNUM");
-    if (!unconvExpNum) {
-        psError(psErrorCodeLast(), false, _("Unable to generate output file from PPSTACK.UNCONV.MASK"));
-        return false;
-    }
-    if (unconvExpNum->type != PM_FPA_FILE_MASK) {
-        psError(PPSTACK_ERR_CONFIG, true, "PPSTACK.UNCONV.EXPNUM is not of type MASK");
-        return false;
-    }
-    unconvExpNum->save = true;
-
+#endif
 
     // Output JPEGs
Index: trunk/ppStack/src/ppStackCleanup.c
===================================================================
--- trunk/ppStack/src/ppStackCleanup.c	(revision 27400)
+++ trunk/ppStack/src/ppStackCleanup.c	(revision 27402)
@@ -86,10 +86,4 @@
         options->outRO = NULL;
 
-        options->expRO->data_exists = false;
-        options->expRO->parent->data_exists = false;
-        options->expRO->parent->parent->data_exists = false;
-        psFree(options->expRO);
-        options->expRO = NULL;
-
         pmFPAview *view = pmFPAviewAlloc(0);// Pointer into FPA hierarchy
         view->chip = view->cell = 0;        // pmFPAviewFreeData doesn't want to deal with readouts
Index: trunk/ppStack/src/ppStackCombineFinal.c
===================================================================
--- trunk/ppStack/src/ppStackCombineFinal.c	(revision 27400)
+++ trunk/ppStack/src/ppStackCombineFinal.c	(revision 27402)
@@ -14,6 +14,6 @@
 //#define TESTING                         // Enable test output
 
-bool ppStackCombineFinal(ppStackThreadData *stack, psArray *covariances, ppStackOptions *options,
-                         pmConfig *config, bool safe, bool normalise, bool grow)
+bool ppStackCombineFinal(pmReadout *target, ppStackThreadData *stack, psArray *covariances,
+                         ppStackOptions *options, pmConfig *config, bool safe, bool normalise, bool grow)
 {
     psAssert(stack, "Require stack");
@@ -21,7 +21,5 @@
     psAssert(config, "Require configuration");
 
-    pmReadout *outRO = options->outRO;                                      // Output readout
-    pmReadout *expRO = options->expRO;                                      // Exposure readout
-    int numCols = outRO->image->numCols, numRows = outRO->image->numRows; // Size of image
+    int numCols = target->image->numCols, numRows = target->image->numRows; // Size of image
 
     psMetadata *recipe = psMetadataLookupMetadata(NULL, config->recipes, PPSTACK_RECIPE); // ppStack recipe
@@ -45,9 +43,6 @@
     }
 
-    if (!outRO->mask) {
-        outRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
-    }
-    if (!expRO->mask) {
-        expRO->mask = psImageAlloc(numCols, numRows, PS_TYPE_IMAGE_MASK);
+    if (!target->mask) {
+        target->mask = psImageAlloc(target->image->numCols, target->image->numRows, PS_TYPE_IMAGE_MASK);
     }
 
@@ -67,6 +62,7 @@
         }
 
-        // call: ppStackReadoutFinal(config, outRO, readouts, rejected)
+        // call: ppStackReadoutFinal(config, target, readouts, rejected)
         psThreadJob *job = psThreadJobAlloc("PPSTACK_FINAL_COMBINE"); // Job to start
+        psArrayAdd(job->args, 1, target);
         psArrayAdd(job->args, 1, thread);
         psArrayAdd(job->args, 1, reject);
@@ -109,11 +105,11 @@
         }
         if (sumWeights > 0.0) {
-            outRO->covariance = psImageCovarianceSum(covariances);
-            psBinaryOp(outRO->covariance->image, outRO->covariance->image, "/",
+            target->covariance = psImageCovarianceSum(covariances);
+            psBinaryOp(target->covariance->image, target->covariance->image, "/",
                        psScalarAlloc(sumWeights, PS_TYPE_F32));
-            psImageCovarianceTransfer(outRO->variance, outRO->covariance);
+            psImageCovarianceTransfer(target->variance, target->covariance);
         }
     } else {
-        outRO->covariance = psImageCovarianceNone();
+        target->covariance = psImageCovarianceNone();
     }
 
@@ -131,6 +127,6 @@
             wcsDone = true;
             pmHDU *inHDU = pmHDUFromCell(inRO->parent); // Template HDU
-            pmHDU *outHDU = pmHDUFromCell(outRO->parent); // Output HDU
-            pmChip *outChip = outRO->parent->parent; // Output chip
+            pmHDU *outHDU = pmHDUFromCell(target->parent); // Output HDU
+            pmChip *outChip = target->parent->parent; // Output chip
             pmFPA *outFPA = outChip->parent; // Output FPA
             if (!outHDU || !inHDU) {
@@ -155,26 +151,6 @@
     }
 
-    // Set exposure time correctly
-    {
-        float exptime = 0.0;            // Summed exposure time
-        for (int i = 0; i < options->num; i++) {
-            if (options->inputMask) {
-                continue;
-            }
-            exptime += options->exposures->data.F32[i];
-        }
-
-        {
-            psMetadataItem *item = psMetadataLookup(outRO->parent->concepts, "CELL.EXPOSURE");
-            item->data.F32 = exptime;
-        }
-        {
-            psMetadataItem *item = psMetadataLookup(outRO->parent->parent->parent->concepts, "FPA.EXPOSURE");
-            item->data.F32 = exptime;
-        }
-    }
-
     // Put version information into the header
-    pmHDU *hdu = pmHDUFromCell(outRO->parent);
+    pmHDU *hdu = pmHDUFromCell(target->parent);
     if (!hdu) {
         psError(PPSTACK_ERR_PROG, false, "Unable to find HDU for output.");
@@ -192,12 +168,12 @@
     psStringAppend(&name, "combined_image_final_%d.fits", pass);
     pass++;
-    ppStackWriteImage(name, NULL, outRO->image, config);
+    ppStackWriteImage(name, NULL, target->image, config);
     psStringSubstitute(&name, "mask", "image");
-    ppStackWriteImage(name, NULL, outRO->mask, config);
+    ppStackWriteImage(name, NULL, target->mask, config);
     psStringSubstitute(&name, "variance", "mask");
-    ppStackWriteImage(name, NULL, outRO->variance, config);
+    ppStackWriteImage(name, NULL, target->variance, config);
     psFree(name);
 
-    pmStackVisualPlotTestImage(outRO->image, "combined_image_final.fits");
+    pmStackVisualPlotTestImage(target->image, "combined_image_final.fits");
 #endif
 
Index: trunk/ppStack/src/ppStackCombineInitial.c
===================================================================
--- trunk/ppStack/src/ppStackCombineInitial.c	(revision 27400)
+++ trunk/ppStack/src/ppStackCombineInitial.c	(revision 27402)
@@ -89,6 +89,4 @@
     }
 
-    ppStackMemDump("initial");
-
 #ifdef TESTING
     ppStackWriteImage("combined_image_initial.fits", NULL, options->outRO->image, config);
Index: trunk/ppStack/src/ppStackCombinePrepare.c
===================================================================
--- trunk/ppStack/src/ppStackCombinePrepare.c	(revision 27400)
+++ trunk/ppStack/src/ppStackCombinePrepare.c	(revision 27402)
@@ -10,6 +10,5 @@
 #include "ppStackLoop.h"
 
-bool ppStackCombinePrepare(const char *outName, const char *expName,
-                           ppStackFileList files, ppStackThreadData *stack,
+bool ppStackCombinePrepare(pmReadout **ro, const char *name, ppStackFileList files, ppStackThreadData *stack,
                            ppStackOptions *options, pmConfig *config)
 {
@@ -33,9 +32,6 @@
     }
 
-    pmCell *cell = pmFPAfileThisCell(config->files, view, outName); // Output cell
-    options->outRO = pmReadoutAlloc(cell); // Output readout
-
-    pmCell *expCell = pmFPAfileThisCell(config->files, view, expName); // Exposure cell
-    options->expRO = pmReadoutAlloc(expCell); // Output readout
+    pmCell *cell = pmFPAfileThisCell(config->files, view, name); // Output cell
+    *ro = pmReadoutAlloc(cell); // Output readout
 
     psFree(view);
@@ -46,10 +42,5 @@
     psImageMaskType maskBad = pmConfigMaskGet(maskBadStr, config); // Bits to mask for bad pixels
 
-    if (!pmReadoutStackDefineOutput(options->outRO, col0, row0, numCols, numRows, true, true, maskBad)) {
-        psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to prepare output.");
-        return false;
-    }
-
-    if (!pmReadoutStackDefineOutput(options->expRO, col0, row0, numCols, numRows, true, true, 0)) {
+    if (!pmReadoutStackDefineOutput(*ro, col0, row0, numCols, numRows, true, true, maskBad)) {
         psError(PPSTACK_ERR_ARGUMENTS, false, "Unable to prepare output.");
         return false;
Index: trunk/ppStack/src/ppStackFiles.c
===================================================================
--- trunk/ppStack/src/ppStackFiles.c	(revision 27400)
+++ trunk/ppStack/src/ppStackFiles.c	(revision 27402)
@@ -23,10 +23,7 @@
 /// Regular (convolved) stack files
 static char *filesStack[] = { "PPSTACK.OUTPUT", "PPSTACK.OUTPUT.MASK", "PPSTACK.OUTPUT.VARIANCE",
-                              "PPSTACK.OUTPUT.EXP", "PPSTACK.OUTPUT.EXPNUM",
-                              "PPSTACK.OUTPUT.JPEG1", "PPSTACK.OUTPUT.JPEG2",
-                              NULL };
+                              "PPSTACK.OUTPUT.JPEG1", "PPSTACK.OUTPUT.JPEG2", NULL };
 /// Unconvolved stack files
-static char *filesUnconv[] = { "PPSTACK.UNCONV", "PPSTACK.UNCONV.MASK", "PPSTACK.UNCONV.VARIANCE",
-                               "PPSTACK.UNCONV.EXP", "PPSTACK.UNCONV.EXPNUM", NULL };
+static char *filesUnconv[] = { "PPSTACK.UNCONV", "PPSTACK.UNCONV.MASK", "PPSTACK.UNCONV.VARIANCE", NULL };
 
 /// Files for photometry
Index: trunk/ppStack/src/ppStackLoop.c
===================================================================
--- trunk/ppStack/src/ppStackLoop.c	(revision 27400)
+++ trunk/ppStack/src/ppStackLoop.c	(revision 27402)
@@ -111,5 +111,5 @@
 
     // Prepare for combination
-    if (!ppStackCombinePrepare("PPSTACK.OUTPUT", "PPSTACK.OUTPUT.EXP", PPSTACK_FILES_STACK,
+    if (!ppStackCombinePrepare(&options->outRO, "PPSTACK.OUTPUT", PPSTACK_FILES_STACK,
                                stack, options, config)) {
         psError(psErrorCodeLast(), false, "Unable to prepare for combination.");
@@ -160,5 +160,6 @@
     // Final combination
     psTrace("ppStack", 2, "Final stack of convolved images....\n");
-    if (!ppStackCombineFinal(stack, options->convCovars, options, config, false, false, true)) {
+    if (!ppStackCombineFinal(options->outRO, stack, options->convCovars, options, config,
+                             false, false, true)) {
         psError(psErrorCodeLast(), false, "Unable to perform final combination.");
         psFree(stack);
@@ -202,5 +203,5 @@
 
         // Prepare for combination
-        if (!ppStackCombinePrepare("PPSTACK.UNCONV", "PPSTACK.UNCONV.EXP", PPSTACK_FILES_UNCONV,
+        if (!ppStackCombinePrepare(&options->unconvRO, "PPSTACK.UNCONV", PPSTACK_FILES_UNCONV,
                                    stack, options, config)) {
             psError(psErrorCodeLast(), false, "Unable to prepare for combination.");
@@ -210,5 +211,5 @@
 
         psTrace("ppStack", 2, "Stack of unconvolved images....\n");
-        if (!ppStackCombineFinal(stack, options->origCovars, options, config,
+        if (!ppStackCombineFinal(options->unconvRO, stack, options->origCovars, options, config,
                                  false, true, false)) {
             psError(psErrorCodeLast(), false, "Unable to perform unconvolved combination.");
@@ -225,14 +226,9 @@
         }
         ppStackFileActivation(config, PPSTACK_FILES_UNCONV, false);
-        options->outRO->data_exists = false;
-        options->outRO->parent->data_exists = false;
-        options->outRO->parent->parent->data_exists = false;
-        psFree(options->outRO);
-        options->outRO = NULL;
-        options->expRO->data_exists = false;
-        options->expRO->parent->data_exists = false;
-        options->expRO->parent->parent->data_exists = false;
-        psFree(options->expRO);
-        options->expRO = NULL;
+        options->unconvRO->data_exists = false;
+        options->unconvRO->parent->data_exists = false;
+        options->unconvRO->parent->parent->data_exists = false;
+        psFree(options->unconvRO);
+        options->unconvRO = NULL;
 
         for (int i = 0; i < options->num; i++) {
Index: trunk/ppStack/src/ppStackLoop.h
===================================================================
--- trunk/ppStack/src/ppStackLoop.h	(revision 27400)
+++ trunk/ppStack/src/ppStackLoop.h	(revision 27402)
@@ -38,6 +38,6 @@
 // Prepare for combination
 bool ppStackCombinePrepare(
-    const char *outName,                // Name of output file
-    const char *expName,                // Name of exposure file
+    pmReadout **readout,                // Readout to set
+    const char *name,                   // Name of file
     ppStackFileList files,              // Files of interest
     ppStackThreadData *stack,           // Stack
@@ -61,4 +61,5 @@
 // Final combination
 bool ppStackCombineFinal(
+    pmReadout *target,                  // Target readout
     ppStackThreadData *stack,           // Stack
     psArray *covariances,               // Covariances
Index: trunk/ppStack/src/ppStackOptions.c
===================================================================
--- trunk/ppStack/src/ppStackOptions.c	(revision 27400)
+++ trunk/ppStack/src/ppStackOptions.c	(revision 27402)
@@ -21,5 +21,4 @@
     psFree(options->psf);
     psFree(options->inputSeeing);
-    psFree(options->exposures);
     psFree(options->inputMask);
     psFree(options->sourceLists);
@@ -33,5 +32,5 @@
     psFree(options->convCovars);
     psFree(options->outRO);
-    psFree(options->expRO);
+    psFree(options->unconvRO);
     psFree(options->inspect);
     psFree(options->rejected);
@@ -62,5 +61,4 @@
     options->zp = NAN;
     options->inputSeeing = NULL;
-    options->exposures = NULL;
     options->targetSeeing = NAN;
     options->inputMask = NULL;
@@ -77,5 +75,5 @@
     options->convCovars = NULL;
     options->outRO = NULL;
-    options->expRO = NULL;
+    options->unconvRO = NULL;
     options->inspect = NULL;
     options->rejected = NULL;
Index: trunk/ppStack/src/ppStackOptions.h
===================================================================
--- trunk/ppStack/src/ppStackOptions.h	(revision 27400)
+++ trunk/ppStack/src/ppStackOptions.h	(revision 27402)
@@ -22,5 +22,4 @@
     psVector *inputSeeing;              // Input seeing FWHMs
     float targetSeeing;                 // Target seeing FWHM
-    psVector *exposures;                // Exposure times
     float sumExposure;                  // Sum of exposure times
     float zp;                           // Zero point for output
@@ -39,5 +38,5 @@
     // Combine initial
     pmReadout *outRO;                   // Output readout
-    pmReadout *expRO;                   // Exposure readout
+    pmReadout *unconvRO;                // Unconvolved readout
     psArray *inspect;                   // Array of arrays of pixels to inspect
     // Rejection
Index: trunk/ppStack/src/ppStackPrepare.c
===================================================================
--- trunk/ppStack/src/ppStackPrepare.c	(revision 27400)
+++ trunk/ppStack/src/ppStackPrepare.c	(revision 27402)
@@ -126,6 +126,4 @@
     options->inputMask = psVectorAlloc(num, PS_TYPE_VECTOR_MASK); // Mask for inputs
     psVectorInit(options->inputMask, 0);
-    options->exposures = psVectorAlloc(options->num, PS_TYPE_F32);
-    psVectorInit(options->exposures, NAN);
 
     pmFPAfileActivate(config->files, false, NULL);
@@ -136,28 +134,28 @@
     }
 
+    psMetadataIterator *fileIter = psMetadataIteratorAlloc(config->files, PS_LIST_HEAD, "^PPSTACK.INPUT$");
+    psMetadataItem *fileItem; // Item from iteration
     psArray *psfs = psArrayAlloc(num); // PSFs for PSF envelope
     int numCols = 0, numRows = 0;   // Size of image
-    options->sumExposure = 0.0;
-    for (int i = 0; i < num; i++) {
-        pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT", i); // File of interest
-        pmCell *cell = pmFPAviewThisCell(view, file->fpa); // Cell of interest
-
-        options->exposures->data.F32[i] = psMetadataLookupF32(NULL, cell->concepts, "CELL.EXPOSURE");
-        options->sumExposure += options->exposures->data.F32[i];
+    int index = 0;                  // Index for file
+    while ((fileItem = psMetadataGetAndIncrement(fileIter))) {
+        assert(fileItem->type == PS_DATA_UNKNOWN);
+        pmFPAfile *inputFile = fileItem->data.V; // An input file
 
         // Get list of PSFs, to determine target PSF
         if (options->convolve) {
-            pmChip *chip = pmFPAviewThisChip(view, file->fpa); // The chip: holds the PSF
+            pmChip *chip = pmFPAviewThisChip(view, inputFile->fpa); // The chip: holds the PSF
             pmPSF *psf = psMetadataLookupPtr(NULL, chip->analysis, "PSPHOT.PSF"); // PSF
             if (!psf) {
                 psError(PPSTACK_ERR_PROG, false, "Unable to find PSF.");
                 psFree(view);
+                psFree(fileIter);
                 psFree(psfs);
                 return false;
             }
-            psfs->data[i] = psMemIncrRefCounter(psf);
+            psfs->data[index] = psMemIncrRefCounter(psf);
             psMetadataRemoveKey(chip->analysis, "PSPHOT.PSF");
 
-            pmCell *cell = pmFPAviewThisCell(view, file->fpa); // Cell of interest
+            pmCell *cell = pmFPAviewThisCell(view, inputFile->fpa); // Cell of interest
             pmHDU *hdu = pmHDUFromCell(cell);
             assert(hdu && hdu->header);
@@ -167,4 +165,5 @@
                 psError(PPSTACK_ERR_PROG, false, "Unable to determine size of image from PSF.");
                 psFree(view);
+                psFree(fileIter);
                 psFree(psfs);
                 return false;
@@ -181,5 +180,5 @@
         pmDetections *detections = NULL;
         if (options->convolve || options->matchZPs || options->photometry || redoPhot) {
-            pmReadout *ro = pmFPAviewThisReadout(view, file->fpa); // Readout with sources
+            pmReadout *ro = pmFPAviewThisReadout(view, inputFile->fpa); // Readout with sources
             detections = psMetadataLookupPtr(NULL, ro->analysis, "PSPHOT.DETECTIONS"); // Sources
             if (!detections) {
@@ -189,16 +188,16 @@
             psAssert (detections->allSources, "missing sources?");
 
-            options->sourceLists->data[i] = psMemIncrRefCounter(detections->allSources);
+            options->sourceLists->data[index] = psMemIncrRefCounter(detections->allSources);
         }
 
         // Re-do photometry if we don't trust the source lists
         if (redoPhot) {
-            psTrace("ppStack", 2, "Photometering input %d of %d....\n", i, num);
+            psTrace("ppStack", 2, "Photometering input %d of %d....\n", index, num);
             pmFPAfileActivate(config->files, false, NULL);
-            ppStackFileActivationSingle(config, PPSTACK_FILES_CONVOLVE, true, i);
+            ppStackFileActivationSingle(config, PPSTACK_FILES_CONVOLVE, true, index);
             if (options->convolve) {
                 pmFPAfileActivate(config->files, true, "PPSTACK.CONV.KERNEL");
             }
-            pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT", i); // File
+            pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT", index); // File
             pmFPAview *photView = ppStackFilesIterateDown(config);
             if (!photView) {
@@ -224,5 +223,8 @@
             ppStackFileActivation(config, PPSTACK_FILES_PREPARE, true);
         }
-    }
+
+        index++;
+    }
+    psFree(fileIter);
 
     psString log = psStringCopy("Input seeing FWHMs:\n"); // Log message
Index: trunk/ppStack/src/ppStackReadout.c
===================================================================
--- trunk/ppStack/src/ppStackReadout.c	(revision 27400)
+++ trunk/ppStack/src/ppStackReadout.c	(revision 27402)
@@ -23,9 +23,8 @@
     psVector *mask = options->inputMask; // Mask for inputs
     psVector *weightings = options->weightings; // Weightings (1/noise^2) for each image
-    psVector *exposures = options->exposures;   // Exposure times for each image
     psVector *addVariance = options->matchChi2; // Additional variance when rejecting
 
     job->results = ppStackReadoutInitial(config, outRO, thread->readouts, mask,
-                                         weightings, exposures, addVariance);
+                                         weightings, addVariance);
     thread->busy = false;
 
@@ -38,23 +37,21 @@
 
     psArray *args = job->args;          // Arguments
-    ppStackThread *thread = args->data[0]; // Thread
-    psArray *reject = args->data[1];    // Rejected pixels for each image
-    ppStackOptions *options = args->data[2]; // Options
-    pmConfig *config = args->data[3];   // Configuration
-    bool safety = PS_SCALAR_VALUE(args->data[4], U8);    // Safety switch on?
-    bool normalise = PS_SCALAR_VALUE(args->data[5], U8); // Normalise images?
+    pmReadout *target = args->data[0];  // Output readout
+    ppStackThread *thread = args->data[1]; // Thread
+    psArray *reject = args->data[2];    // Rejected pixels for each image
+    ppStackOptions *options = args->data[3]; // Options
+    pmConfig *config = args->data[4];   // Configuration
+    bool safety = PS_SCALAR_VALUE(args->data[5], U8);    // Safety switch on?
+    bool normalise = PS_SCALAR_VALUE(args->data[6], U8); // Normalise images?
 
     psVector *mask = options->inputMask; // Mask for inputs
     psVector *weightings = options->weightings; // Weightings (1/noise^2) for each image
-    psVector *exposures = options->exposures;   // Exposure times for each image
     psVector *addVariance = options->matchChi2; // Additional variance when rejecting
     psVector *norm = normalise ? options->norm : NULL; // Normalisations to apply to images
 
-    bool status = ppStackReadoutFinal(config, options->outRO, options->expRO, thread->readouts, mask, reject,
-                                      weightings, exposures, addVariance, safety, norm); // Status of operation
+    bool status = ppStackReadoutFinal(config, target, thread->readouts, mask, reject,
+                                      weightings, addVariance, safety, norm); // Status of operation
 
     thread->busy = false;
-
-    psAssert(status, "Stacking failed.");
 
     return status;
@@ -104,6 +101,5 @@
 
 psArray *ppStackReadoutInitial(const pmConfig *config, pmReadout *outRO, const psArray *readouts,
-                               const psVector *mask, const psVector *weightings, const psVector *exposures,
-                               const psVector *addVariance)
+                               const psVector *mask, const psVector *weightings, const psVector *addVariance)
 {
     assert(config);
@@ -153,9 +149,8 @@
         }
 
-        stack->data[i] = pmStackDataAlloc(ro, weightings->data.F32[i], exposures->data.F32[i],
-                                          addVariance->data.F32[i]);
-    }
-
-    if (!pmStackCombine(outRO, NULL, stack, maskVal | maskBad, maskSuspect, maskBad, kernelSize, iter,
+        stack->data[i] = pmStackDataAlloc(ro, weightings->data.F32[i], addVariance->data.F32[i]);
+    }
+
+    if (!pmStackCombine(outRO, stack, maskVal | maskBad, maskSuspect, maskBad, kernelSize, iter,
                         combineRej, combineSys, combineDiscard, useVariance, safe, false)) {
         psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts with rejection.");
@@ -192,12 +187,10 @@
 
 
-bool ppStackReadoutFinal(const pmConfig *config, pmReadout *outRO, pmReadout *expRO, const psArray *readouts,
+bool ppStackReadoutFinal(const pmConfig *config, pmReadout *outRO, const psArray *readouts,
                          const psVector *mask, const psArray *rejected, const psVector *weightings,
-                         const psVector *exposures, const psVector *addVariance, bool safety,
-                         const psVector *norm)
+                         const psVector *addVariance, bool safety, const psVector *norm)
 {
     assert(config);
     assert(outRO);
-    assert(expRO);
     assert(readouts);
     assert(!rejected || readouts->n == rejected->n);
@@ -245,5 +238,5 @@
         }
 
-        pmStackData *data = pmStackDataAlloc(ro, weightings->data.F32[i], exposures->data.F32[i],
+        pmStackData *data = pmStackDataAlloc(ro, weightings->data.F32[i],
                                              addVariance ? addVariance->data.F32[i] : NAN);
         data->reject = rejected ? psMemIncrRefCounter(rejected->data[i]) : NULL;
@@ -257,5 +250,5 @@
     }
 
-    if (!pmStackCombine(outRO, expRO, stack, maskVal | maskBad, maskSuspect, maskBad, 0, iter, combineRej,
+    if (!pmStackCombine(outRO, stack, maskVal | maskBad, maskSuspect, maskBad, 0, iter, combineRej,
                         combineSys, combineDiscard, useVariance, safe, rejected)) {
         psError(PS_ERR_UNKNOWN, false, "Unable to combine input readouts.");
@@ -266,14 +259,9 @@
     pmCell *outCell = outRO->parent;    // Output cell
     pmChip *outChip = outCell->parent;  // Output chip
+
     outRO->data_exists = true;
     outCell->data_exists = true;
     outChip->data_exists = true;
 
-    pmCell *expCell = expRO->parent;    // Exposure cell
-    pmChip *expChip = expCell->parent;  // Exposure chip
-    expRO->data_exists = true;
-    expCell->data_exists = true;
-    expChip->data_exists = true;
-
     psFree(stack);
 
Index: trunk/ppStack/src/ppStackReject.c
===================================================================
--- trunk/ppStack/src/ppStackReject.c	(revision 27400)
+++ trunk/ppStack/src/ppStackReject.c	(revision 27402)
@@ -162,4 +162,6 @@
         psLogMsg("ppStack", PS_LOG_INFO, "Time to perform rejection on image %d: %f sec", i,
                  psTimerClear("PPSTACK_REJECT"));
+
+        ppStackMemDump("reject");
     }
 
Index: trunk/ppStack/src/ppStackSources.c
===================================================================
--- trunk/ppStack/src/ppStackSources.c	(revision 27400)
+++ trunk/ppStack/src/ppStackSources.c	(revision 27402)
@@ -64,6 +64,11 @@
 
     if (!options->matchZPs && !options->photometry) {
-        options->norm = psVectorAlloc(options->num, PS_TYPE_F32);
-        psVectorInit(options->norm, 0.0);
+        int num = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); // Number of inputs
+        options->norm = psVectorAlloc(num, PS_TYPE_F32);
+        psVectorInit (options->norm, 0.0);
+
+        // XXX do I need to set this?
+        // options->sumExposure = sumExpTime;
+
         return true;
     }
@@ -132,5 +137,5 @@
     }
 
-    int num = options->num;             // Number of inputs
+    int num = psMetadataLookupS32(NULL, config->arguments, "INPUTS.NUM"); // Number of inputs
     psAssert(num == sourceLists->n, "Wrong number of source lists: %ld\n", sourceLists->n);
 
@@ -141,4 +146,5 @@
     float airmassTerm = NAN;            // Airmass term
     float zpTarget = NAN;               // Target zero point
+    float sumExpTime = 0.0;             // Sum of the exposure time
     int numGoodImages = 0;              // Number of good images
     for (int i = 0; i < num; i++) {
@@ -154,4 +160,5 @@
 
         pmFPAfile *file = pmFPAfileSelectSingle(config->files, "PPSTACK.INPUT", i); // File of interest
+        pmCell *cell = pmFPAviewThisCell(view, file->fpa); // Cell of interest
 
 #if defined(TESTING) && 0
@@ -170,5 +177,5 @@
 #endif
 
-        float exptime = options->exposures->data.F32[i]; // Exposure time
+        float exptime = psMetadataLookupF32(NULL, cell->concepts, "CELL.EXPOSURE"); // Exposure time
         float airmass = psMetadataLookupF32(NULL, file->fpa->concepts, "FPA.AIRMASS"); // Airmass
         const char *expFilter = psMetadataLookupStr(NULL, file->fpa->concepts, "FPA.FILTER"); // Filter name
@@ -214,5 +221,9 @@
 
         zp->data.F32[i] = airmassTerm * airmass + 2.5 * log10(exptime);
-    }
+        sumExpTime += exptime;
+
+    }
+
+    options->sumExposure = sumExpTime;
 
     if (numGoodImages == 0) {
@@ -280,5 +291,5 @@
                 }
                 psArray *sources = sourceLists->data[i]; // Sources of interest
-                float magCorr = zp->data.F32[i] + trans->data.F32[i] - 2.5*log10(options->sumExposure);
+                float magCorr = zp->data.F32[i] + trans->data.F32[i] - 2.5*log10(sumExpTime);
                 if (zpExpNum == numGoodImages) {
                     // Using measured zero points, so attempt to set target zero point
Index: trunk/ppStack/src/ppStackThread.c
===================================================================
--- trunk/ppStack/src/ppStackThread.c	(revision 27400)
+++ trunk/ppStack/src/ppStackThread.c	(revision 27402)
@@ -284,5 +284,5 @@
 
     {
-        psThreadTask *task = psThreadTaskAlloc("PPSTACK_FINAL_COMBINE", 6);
+        psThreadTask *task = psThreadTaskAlloc("PPSTACK_FINAL_COMBINE", 7);
         task->function = &ppStackReadoutFinalThread;
         psThreadTaskAdd(task);
