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
