Index: trunk/ppStack/src/ppStackLoop.c
===================================================================
--- trunk/ppStack/src/ppStackLoop.c	(revision 20997)
+++ trunk/ppStack/src/ppStackLoop.c	(revision 21092)
@@ -254,4 +254,5 @@
     psArray *sourceLists = psArrayAlloc(num); // Individual lists of sources for matching
     pmPSF *targetPSF = NULL;            // Target PSF
+    float sumExposure = NAN;            // Sum of exposure times
     if (psMetadataLookupBool(NULL, config->arguments, "HAVE.PSF")) {
         pmFPAfileActivate(config->files, false, NULL);
@@ -348,5 +349,6 @@
 
         // Zero point calibration
-        if (!ppStackSourcesTransparency(sourceLists, view, config)) {
+        sumExposure = ppStackSourcesTransparency(sourceLists, view, config);
+        if (!isfinite(sumExposure) || sumExposure <= 0) {
             psError(PS_ERR_UNKNOWN, false, "Unable to calculate transparency differences");
             psFree(sourceLists);
@@ -407,4 +409,6 @@
     psVector *weightings = psVectorAlloc(num, PS_TYPE_F32); // Combination weightings for images (1/noise^2)
     psVectorInit(weightings, NAN);
+    psList *fpaList = psListAlloc(NULL); // List of input FPAs, for concept averaging
+    psList *cellList = psListAlloc(NULL); // List of input cells, for concept averaging
     for (int i = 0; i < num; i++) {
         psTrace("ppStack", 2, "Convolving input %d of %d to target PSF....\n", i, num);
@@ -475,5 +479,10 @@
         writeImage(weightNames->data[i], hdu->header, readout->weight, config);
 
-        cells->data[i] = psMemIncrRefCounter(readout->parent);
+        pmCell *inCell = readout->parent; // Input cell
+
+        psListAdd(cellList, PS_LIST_TAIL, inCell);
+        psListAdd(fpaList, PS_LIST_TAIL, inCell->parent->parent);
+
+        cells->data[i] = psMemIncrRefCounter(inCell);
         if (!filesIterateUp(config)) {
             return false;
@@ -496,4 +505,30 @@
         return false;
     }
+
+
+    // Update concepts for output
+    {
+        pmFPAview view;                 // View for output
+        view.chip = view.cell = view.readout = 0;
+        pmCell *outCell = pmFPAfileThisCell(config->files, &view, "PPSTACK.OUTPUT"); // Output cell
+        pmFPA *outFPA = outCell->parent->parent; // Output FPA
+        pmConceptsAverageFPAs(outFPA, fpaList);
+        pmConceptsAverageCells(outCell, cellList, NULL, NULL, true);
+        psFree(fpaList);
+        psFree(cellList);
+
+        // Update the value of a concept
+#define UPDATE_CONCEPT(SOURCE, NAME, VALUE) { \
+            psMetadataItem *item = psMetadataLookup(SOURCE->concepts, NAME); \
+            psAssert(item, "Concept should be present"); \
+            psAssert(item->type == PS_TYPE_F32, "Concept should be F32"); \
+            item->data.F32 = VALUE; \
+        }
+
+        UPDATE_CONCEPT(outFPA,  "FPA.EXPOSURE",  sumExposure);
+        UPDATE_CONCEPT(outCell, "CELL.EXPOSURE", sumExposure);
+        UPDATE_CONCEPT(outCell, "CELL.DARKTIME", NAN);
+    }
+
 
     // Reject images out-of-hand on the basis of their match chi^2
@@ -626,25 +661,4 @@
             return false;
         }
-
-        psList *fpaList = psListAlloc(NULL); // List of input FPAs, for concept averaging
-        psList *cellList = psListAlloc(NULL); // List of input cells, for concept averaging
-        for (int i = 0; i < num; i++) {
-            pmCell *inCell = cells->data[i]; // Input cell
-            if (!inCell) {
-                exptimes->data.F32[i] = 0.0;
-                continue;
-            }
-            exptimes->data.F32[i] = psMetadataLookupF32(NULL, inCell->concepts, "CELL.EXPOSURE");
-            psListAdd(cellList, PS_LIST_TAIL, inCell);
-            psListAdd(fpaList, PS_LIST_TAIL, inCell->parent->parent);
-        }
-
-        // Copy concepts
-        pmChip *outChip = outCell->parent;  // Output chip
-        pmFPA *outFPA = outChip->parent;    // Output FPA
-        pmConceptsAverageFPAs(outFPA, fpaList);
-        pmConceptsAverageCells(outCell, cellList, NULL, NULL, true);
-        psFree(fpaList);
-        psFree(cellList);
 
         psFree(cells);
@@ -977,10 +991,8 @@
     // Close up
     bool wcsDone = false;           // Have we done the WCS?
-    float totExposure = 0.0;            // Total exposure time
     for (int i = 0; i < num; i++) {
         if (inputMask->data.U8[i]) {
             continue;
         }
-        totExposure += exptimes->data.F32[i];
 
         ppStackThread *thread = stack->threads->data[0]; // Representative stack
