Index: trunk/ppMerge/src/ppMerge.c
===================================================================
--- trunk/ppMerge/src/ppMerge.c	(revision 6903)
+++ trunk/ppMerge/src/ppMerge.c	(revision 7061)
@@ -1,5 +1,6 @@
 #include <stdio.h>
-#include "pslib.h"
-#include "pmConcepts.h"
+#include <pslib.h>
+#include <psmodules.h>
+
 #include "ppMerge.h"
 #include "ppMem.h"
@@ -13,27 +14,40 @@
 
     // Parse the configuration and arguments
-    ppImageConfig(config, argc, argv);
-
-    // Open the input image, output image, output mask
-    // Get camera configuration from header if not already defined
+    // Open the input image(s)
+    // Determine camera, format from header if not already defined
     // Construct camera in preparation for reading
-    ppImageParseCamera(data, config);
+    pmConfig *config = ppMergeConfig(&argc, argv);
 
     // Set various tasks (define optional operations)
-    ppImageOptionsParse(data, options, config);
+    ppMergeOptions *options = ppMergeOptionsParse(config);
 
-    // open detrend images, load headers, optionally load pixels
-    ppImageParseDetrend(data, options, config);
+    // Check the inputs
+    ppMergeData *data = ppMergeCheckInputs(options, config);
+    if (!data) {
+        psError("Not enough valid input files.\n");
+        exit(EXIT_FAILURE);
+    }
 
-    // Image Arithmetic Loop
-    ppImageLoop(data, options, config);
+    // Measure the background in each image
+    psImage *scale = NULL;              // The scalings
+    psImage *zero = NULL;               // The zeros
+    ppMergeScaleZero(&scale, &zero, data, options, config);
+
+    // Do the combination and write
+    ppMergeCombine(scale, zero, data, options, config);
 
     // Cleaning up
     psFree(data);
+    psFree(scale);
+    psFree(zero);
     psFree(options);
     psFree(config);
+
     psTimerStop();
     psTraceReset();
+    psErrorClear();
     pmConceptsDone();
+    pmConfigDone();
+
     ppMemCheck();
 
