Index: trunk/ppMerge/src/ppMergeOptions.c
===================================================================
--- trunk/ppMerge/src/ppMergeOptions.c	(revision 7061)
+++ trunk/ppMerge/src/ppMergeOptions.c	(revision 7067)
@@ -2,4 +2,7 @@
 #include <pslib.h>
 #include <psmodules.h>
+
+#include "ppMerge.h"
+#include "ppMergeOptions.h"
 
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -7,11 +10,10 @@
 //////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
-#if 0
 // Free function
 static void mergeOptionsFree(ppMergeOptions *options // Options to free
     )
 {
+    psFree(options->combine);
 }
-#endif
 
 // Allocator
@@ -19,5 +21,5 @@
 {
     ppMergeOptions *options = psAlloc(sizeof(ppMergeOptions)); // The options, to return
-    // psMemSetDeallocator(options, (psFreeFunc)mergeOptionsFree);
+    psMemSetDeallocator(options, (psFreeFunc)mergeOptionsFree);
 
     options->rows = 0;
@@ -29,11 +31,11 @@
     options->background = PS_STAT_SAMPLE_MEDIAN;
     options->onOff = 0;
-    options->combine = PS_STAT_SAMPLE_MEAN;
-    options->ref = 3.0;
-    options->iter = 1;
-    options->fracHigh = 0.0;
-    options->fracLow = 0.0;
-    options->nKeep = 1;
-    options->maskVal = 0xffff;
+    options->combine = pmCombineParamsAlloc(PS_STAT_SAMPLE_MEAN);
+    options->combine->rej = 3.0;
+    options->combine->iter = 1;
+    options->combine->fracHigh = 0.0;
+    options->combine->fracLow = 0.0;
+    options->combine->nKeep = 1;
+    options->combine->maskVal = 0xff;
 
     return options;
@@ -84,21 +86,28 @@
 
 // Parse the options
-ppMergeOptions *ppMergeOptionsParse(ppConfig *config // Configuration
+ppMergeOptions *ppMergeOptionsParse(pmConfig *config // Configuration
     )
 {
     ppMergeOptions *options = ppMergeOptionsAlloc(); // The merge options
 
+    bool mdok = true;                   // Status of MD lookup
+    psMetadata *recipe = psMetadataLookupMD(&mdok, config->recipes, RECIPENAME); // Recipe information
+    if (!mdok || !recipe) {
+        psError(PS_ERR_IO, true, "Unable to find recipe %s", RECIPENAME);
+        exit(EXIT_FAILURE);
+    }
+
     // First, deal with the recipe.  These are parameters that will typically be constant for a camera.
-    OPTION_PARSE(options->rows,         config->recipe, "ROWS",      U16 );
-    OPTION_PARSE(options->minElectrons, config->recipe, "ELECTRONS", F32 );
-    OPTION_PARSE(options->sample,       config->recipe, "SAMPLE",    S32 );
-    OPTION_PARSE(options->rej,          config->recipe, "REJ",       F32 );
-    OPTION_PARSE(options->iter,         config->recipe, "ITER",      S32 );
-    OPTION_PARSE(options->fracHigh,     config->recipe, "FRACHIGH",  F32 );
-    OPTION_PARSE(options->fracLow,      config->recipe, "FRACLOW",   F32 );
-    OPTION_PARSE(options->nKeep,        config->recipe, "NKEEP",     S32 );
-    OPTION_PARSE(options->maskVal,      config->recipe, "MASKVAL",   U8  );
-    options->combine = parseStat(config->recipe, "COMBINE");
-    options->background = parseStat(config->recipe, "BACKGROUND");
+    OPTION_PARSE(options->rows,              recipe, "ROWS",      U16 );
+    OPTION_PARSE(options->minElectrons,      recipe, "ELECTRONS", F32 );
+    OPTION_PARSE(options->sample,            recipe, "SAMPLE",    S32 );
+    OPTION_PARSE(options->combine->rej,      recipe, "REJ",       F32 );
+    OPTION_PARSE(options->combine->iter,     recipe, "ITER",      S32 );
+    OPTION_PARSE(options->combine->fracHigh, recipe, "FRACHIGH",  F32 );
+    OPTION_PARSE(options->combine->fracLow,  recipe, "FRACLOW",   F32 );
+    OPTION_PARSE(options->combine->nKeep,    recipe, "NKEEP",     S32 );
+    OPTION_PARSE(options->combine->maskVal,  recipe, "MASKVAL",   U8  );
+    options->combine->combine = parseStat(recipe, "COMBINE");
+    options->background       = parseStat(recipe, "BACKGROUND");
 
     // Now the command-line options.  These are parameters that depend on what type of frame is being combined
@@ -127,10 +136,10 @@
 
     // Or you can set them individually
-    OPTION_PARSE(options->zero,    config->recipe, "-zero",    Bool);
-    OPTION_PARSE(options->scale,   config->recipe, "-scale",   Bool);
-    OPTION_PARSE(options->exptime, config->recipe, "-exptime", Bool);
+    OPTION_PARSE(options->zero,    config->arguments, "-zero",    Bool);
+    OPTION_PARSE(options->scale,   config->arguments, "-scale",   Bool);
+    OPTION_PARSE(options->exptime, config->arguments, "-exptime", Bool);
 
     // Number of on/off images
-    OPTION_PARSE(options->onoff, config->recipe, "-onoff", S32);
+    OPTION_PARSE(options->onOff, config->arguments, "-onoff", S32);
 
     return options;
