Index: trunk/ppMerge/src/ppMerge.c
===================================================================
--- trunk/ppMerge/src/ppMerge.c	(revision 7061)
+++ trunk/ppMerge/src/ppMerge.c	(revision 7064)
@@ -4,11 +4,15 @@
 
 #include "ppMerge.h"
-#include "ppMem.h"
+#include "ppMergeConfig.h"
+#include "ppMergeData.h"
+#include "ppMergeOptions.h"
+#include "ppMergeCheckInputs.h"
+#include "ppMergeBackground.h"
+#include "ppMergeCombine.h"
+
+//#include "ppMem.h"
 
 int main(int argc, char **argv)
 {
-    ppMergeOptions *options = ppMergeOptionsAlloc();
-    ppConfig *config = ppConfigAlloc();
-
     psTimerStart(TIMERNAME);
 
@@ -25,5 +29,5 @@
     ppMergeData *data = ppMergeCheckInputs(options, config);
     if (!data) {
-        psError("Not enough valid input files.\n");
+        psError(PS_ERR_IO, false, "Not enough valid input files.\n");
         exit(EXIT_FAILURE);
     }
@@ -50,5 +54,5 @@
     pmConfigDone();
 
-    ppMemCheck();
+//    ppMemCheck();
 
     return EXIT_SUCCESS;
Index: trunk/ppMerge/src/ppMerge.h
===================================================================
--- trunk/ppMerge/src/ppMerge.h	(revision 7061)
+++ trunk/ppMerge/src/ppMerge.h	(revision 7064)
@@ -2,8 +2,5 @@
 #define PP_MERGE_H
 
-#include <stdio.h>
-#include <pslib.h>
-#include <psmodules.h>
+#define TIMERNAME "ppMerge"
 
-#define RECIPE "PPMERGE"                // Name of the recipe to use
-
+#endif
Index: trunk/ppMerge/src/ppMergeBackground.c
===================================================================
--- trunk/ppMerge/src/ppMergeBackground.c	(revision 7061)
+++ trunk/ppMerge/src/ppMergeBackground.c	(revision 7064)
@@ -34,6 +34,6 @@
 
 // Get the scale and zero for each chip of each input
-bool ppMergeScaleZero(ppImage **scales, // The scales for each integration/cell
-                      ppImage **zeros, // The zeroes for each integration/cell
+bool ppMergeScaleZero(psImage **scales, // The scales for each integration/cell
+                      psImage **zeros, // The zeroes for each integration/cell
                       ppMergeData *data,// The data
                       const ppMergeOptions *options, // The options
@@ -76,10 +76,10 @@
         psFits *inFile = psFitsOpen(filenames->data[i], "r"); // The FITS file to read
         if (!inFile) {
-            psErrorPrint(PS_ERR_IO, false, "Unable to open input file %s --- ignored.\n", name);
+            psLogMsg(__func__, PS_LOG_WARN, "Unable to open input file %s --- ignored.\n", name);
             status = false;
             continue;
         }
 
-        pmFPA *fpa = in->data[i];       // The FPA for this input
+        pmFPA *fpa = data->in->data[i]; // The FPA for this input
         int cellNum = -1;               // Number of the cell
         psArray *chips = fpa->chips;    // Array of chips
@@ -106,5 +106,6 @@
                 if (options->exptime) {
                     bool mdok = true;   // Status of MD lookup
-                    exptime->data.F64[i][cellNum] = psMetadataLookup(&mdok, cell->concepts, "CELL.EXPOSURE");
+                    exptime->data.F64[i][cellNum] = psMetadataLookupF32(&mdok, cell->concepts,
+                                                                        "CELL.EXPOSURE");
                     if (!mdok || isnan(exptime->data.F64[i][cellNum])) {
                         psLogMsg(__func__, PS_LOG_WARN, "CELL.EXPOSURE for file %s chip %d cell %d is not "
@@ -139,9 +140,9 @@
                     if (options->scale) {
                         bool mdok = true;   // Status of MD lookup
-                        gain->data.F32[cellNum] = psMetadataLookupF32(&mdok, cell->concepts, "CELL.GAIN");
-                        if (!mdok || isnan(gain->data.F32[cellNum])) {
+                        gains->data.F32[cellNum] = psMetadataLookupF32(&mdok, cell->concepts, "CELL.GAIN");
+                        if (!mdok || isnan(gains->data.F32[cellNum])) {
                             psLogMsg(__func__, PS_LOG_WARN, "CELL.GAIN for file %s chip %d cell %d is not "
                                      "set.\n", name, j, k);
-                            gain->data.F32[cellNum] = NAN;
+                            gains->data.F32[cellNum] = NAN;
                             status = false;
                         }
@@ -150,12 +151,12 @@
                     // Get the background
                     psImageStats(bgStats, image, readout->mask, options->maskVal);
-                    background[i][cellNum] = getStat(bgStats, options->background);
-                }
-
-                psCellFreeData(cell);
+                    background->data.F64[i][cellNum] = getStat(bgStats, options->background);
+                }
+
+                pmCellFreeData(cell);
             }
-            psChipFreeData(chip);
-        }
-        psFPAFreeData(fpa);
+            pmChipFreeData(chip);
+        }
+        pmFPAFreeData(fpa);
         psFitsClose(inFile);
     }
Index: trunk/ppMerge/src/ppMergeBackground.h
===================================================================
--- trunk/ppMerge/src/ppMergeBackground.h	(revision 7061)
+++ trunk/ppMerge/src/ppMergeBackground.h	(revision 7064)
@@ -2,7 +2,13 @@
 #define PP_MERGE_BACKGROUND_H
 
+#include <pslib.h>
+#include <psmodules.h>
+
+#include "ppMergeData.h"
+#include "ppMergeOptions.h"
+
 // Get the scale and zero for each chip of each input
-bool ppMergeScaleZero(ppImage **scales, // The scales for each integration/cell
-                      ppImage **zeros, // The zeroes for each integration/cell
+bool ppMergeScaleZero(psImage **scales, // The scales for each integration/cell
+                      psImage **zeros, // The zeroes for each integration/cell
                       ppMergeData *data,// The data
                       const ppMergeOptions *options, // The options
Index: trunk/ppMerge/src/ppMergeCheckInputs.h
===================================================================
--- trunk/ppMerge/src/ppMergeCheckInputs.h	(revision 7061)
+++ trunk/ppMerge/src/ppMergeCheckInputs.h	(revision 7064)
@@ -2,7 +2,11 @@
 #define PP_MERGE_CHECK_INPUTS_H
 
+#include <psmodules.h>
+#include "ppMergeOptions.h"
+#include "ppMergeData.h"
+
 // Check input files to make sure everything's consistent
-bool ppMergeCheckInputs(ppMergeOptions *options, // Options
-                        const pmConfig *config // Configuration
+ppMergeData *ppMergeCheckInputs(ppMergeOptions *options, // Options
+                                const pmConfig *config // Configuration
     );
 
Index: trunk/ppMerge/src/ppMergeCombine.h
===================================================================
--- trunk/ppMerge/src/ppMergeCombine.h	(revision 7061)
+++ trunk/ppMerge/src/ppMergeCombine.h	(revision 7064)
@@ -4,4 +4,7 @@
 #include <pslib.h>
 #include <psmodules.h>
+
+#include "ppMergeData.h"
+#include "ppMergeOptions.h"
 
 // Combine readouts
Index: trunk/ppMerge/src/ppMergeConfig.h
===================================================================
--- trunk/ppMerge/src/ppMergeConfig.h	(revision 7061)
+++ trunk/ppMerge/src/ppMergeConfig.h	(revision 7064)
@@ -1,4 +1,6 @@
 #ifndef PP_MERGE_CONFIG_H
 #define PP_MERGE_CONFIG_H
+
+#include <psmodules.h>
 
 // Get the configuration information
Index: trunk/ppMerge/src/ppMergeData.h
===================================================================
--- trunk/ppMerge/src/ppMergeData.h	(revision 7061)
+++ trunk/ppMerge/src/ppMergeData.h	(revision 7064)
@@ -1,4 +1,7 @@
 #ifndef PP_MERGE_DATA_H
 #define PP_MERGE_DATA_H
+
+#include <pslib.h>
+#include <psmodules.h>
 
 // Container for the data
Index: trunk/ppMerge/src/ppMergeOptions.h
===================================================================
--- trunk/ppMerge/src/ppMergeOptions.h	(revision 7061)
+++ trunk/ppMerge/src/ppMergeOptions.h	(revision 7064)
@@ -2,5 +2,6 @@
 #define PP_MERGE_OPTIONS_H
 
-#include <psModules.h>
+#include <pslib.h>
+#include <psmodules.h>
 
 // Mode of on/off pairs; the value corresponds to how many images are in each set
