Index: trunk/ippTools/src/dettoolConfig.c
===================================================================
--- trunk/ippTools/src/dettoolConfig.c	(revision 7058)
+++ trunk/ippTools/src/dettoolConfig.c	(revision 7063)
@@ -42,5 +42,5 @@
     psMetadataAddStr(defineArgs, PS_LIST_TAIL, "-exp_id",  0,
         "include this exposure (XXX more then one)", NULL);
-    psMetadataAddStr(defineArgs, PS_LIST_TAIL, "-dettype",  0,
+    psMetadataAddStr(defineArgs, PS_LIST_TAIL, "-det_type",  0,
         "define the type of detrend run", NULL);
 
@@ -100,5 +100,5 @@
         "search for iteration number", NULL);
 
-#define PXTOOL_MODE(option, modeval, args) \
+#define PXTOOL_MODE(option, modeval, argset) \
     if ((N = psArgumentGet (argc, argv, option))) { \
         psArgumentRemove (N, &argc, argv); \
@@ -107,10 +107,9 @@
         } \
         config->mode = modeval; \
-        argSet = psMemIncrRefCounter(args); \
+        config->args = psMemIncrRefCounter(argset); \
     }
 
     // find which mode we're running under
     int N = 0;
-    psMetadata *argSet = NULL;
     config->mode = DETTOOL_MODE_NONE;
     if ((N = psArgumentGet (argc, argv, "-define"))) {
@@ -120,5 +119,5 @@
         }
         config->mode = DETTOOL_MODE_DEFINE;
-        argSet = psMemIncrRefCounter(defineArgs);
+        config->args = psMemIncrRefCounter(defineArgs);
     }
     PXTOOL_MODE("-raw",             DETTOOL_MODE_RAW,           rawArgs);
@@ -132,5 +131,5 @@
         argErr = true;
         fprintf (stderr, "mode argument is required\n");
-    } else if (! psArgumentParse(argSet, &argc, argv) || argc != 1) {
+    } else if (! psArgumentParse(config->args, &argc, argv) || argc != 1) {
         argErr = true;
         fprintf (stderr, "error parsing arguments\n");
@@ -174,8 +173,7 @@
     // setup search criterion
 #define addWhereStr(name) \
-    if ((str = psMetadataLookupStr(&status, argSet, "-" #name))) { \
-        if (!psMetadataAddStr(where, PS_LIST_TAIL, #name, 0, "==", str)) {\
+    if ((str = psMetadataLookupStr(&status, config->args, "-" #name))) { \
+        if (!psMetadataAddStr(config->where, PS_LIST_TAIL, #name, 0, "==", str)) {\
             psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
-            psFree(where); \
             exit(EXIT_FAILURE); \
         } \
@@ -183,5 +181,5 @@
 
     // generate SQL where claus
-    psMetadata *where = psMetadataAlloc();
+    config->where = psMetadataAlloc();
 
 {
@@ -192,8 +190,7 @@
     addWhereStr(exp_id);
     // convert '-inst' to 'camera'
-    if ((str = psMetadataLookupStr(&status, argSet, "-inst"))) {
-        if (!psMetadataAddStr(where, PS_LIST_TAIL, "camera", 0, "==", str)) {
+    if ((str = psMetadataLookupStr(&status, config->args, "-inst"))) {
+        if (!psMetadataAddStr(config->where, PS_LIST_TAIL, "camera", 0, "==", str)) {
             psError(PS_ERR_UNKNOWN, false, "failed to add item camera");
-            psFree(where);
             exit(EXIT_FAILURE);
         }
@@ -201,8 +198,7 @@
     addWhereStr(telescope);
     addWhereStr(exp_type);
-    if ((n = psMetadataLookupS32(&status, argSet, "-imfiles"))) {
-        if (!psMetadataAddS32(where, PS_LIST_TAIL, "imfiles", 0, "==", n)) {
+    if ((n = psMetadataLookupS32(&status, config->args, "-imfiles"))) {
+        if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "imfiles", 0, "==", n)) {
             psError(PS_ERR_UNKNOWN, false, "failed to add item imfiles");
-            psFree(where);
             exit(EXIT_FAILURE);
         }
@@ -211,20 +207,16 @@
     addWhereStr(stats);
     addWhereStr(recipe);
-    if ((n = psMetadataLookupS32(&status, argSet, "-p1_version"))) {
-        if (!psMetadataAddS32(where, PS_LIST_TAIL, "p1_version", 0, "==", n)) {
+    if ((n = psMetadataLookupS32(&status, config->args, "-p1_version"))) {
+        if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "p1_version", 0, "==", n)) {
             psError(PS_ERR_UNKNOWN, false, "failed to add item p1_version");
-            psFree(where);
             exit(EXIT_FAILURE);
         }
     }
 }
-    psFree(argSet);
-
-    if (where->list->n < 1) {
-        psFree(where);
-        where = NULL;
-    }
-
-    config->where = where;
+
+    if (config->where->list->n < 1) {
+        psFree(config->where);
+        config->where = NULL;
+    }
 
     // define Database handle, if used
Index: trunk/ippTools/src/guidetoolConfig.c
===================================================================
--- trunk/ippTools/src/guidetoolConfig.c	(revision 7058)
+++ trunk/ippTools/src/guidetoolConfig.c	(revision 7063)
@@ -91,16 +91,14 @@
 
     // parse CLI for these options
-    psMetadata *argSet = NULL;
     switch (config->mode) {
         case PX_MODE_PENDING:
-            argSet = pendingArgs;
+            config->args = psMemIncrRefCounter(pendingArgs);
             break;
         case PX_MODE_DEFINE:
-            argSet = defineArgs;
+            config->args = psMemIncrRefCounter(defineArgs);
             break;
         default:
-            argSet = args;
+            config->args = psMemIncrRefCounter(args);
     }
-    psMemIncrRefCounter(argSet);
 
     bool argErr = false;
@@ -108,5 +106,5 @@
         argErr = true;
         fprintf (stderr, "mode argument is required\n");
-    } else if (! psArgumentParse(argSet, &argc, argv) || argc != 1) {
+    } else if (! psArgumentParse(config->args, &argc, argv) || argc != 1) {
         argErr = true;
         fprintf (stderr, "error parsing arguments\n");
@@ -133,8 +131,7 @@
     // setup search criterion
 #define addWhereStr(name) \
-    if ((str = psMetadataLookupStr(&status, argSet, "-" #name))) { \
-        if (!psMetadataAddStr(where, PS_LIST_TAIL, #name, 0, "==", str)) {\
+    if ((str = psMetadataLookupStr(&status, config->args, "-" #name))) { \
+        if (!psMetadataAddStr(config->where, PS_LIST_TAIL, #name, 0, "==", str)) {\
             psError(PS_ERR_UNKNOWN, false, "failed to add item " #name); \
-            psFree(where); \
             exit(EXIT_FAILURE); \
         } \
@@ -142,5 +139,5 @@
 
     // generate SQL where claus
-    psMetadata *where = psMetadataAlloc();
+    config->where = psMetadataAlloc();
 
 {
@@ -151,8 +148,7 @@
     addWhereStr(exp_id);
     // convert '-inst' to 'camera'
-    if ((str = psMetadataLookupStr(&status, argSet, "-inst"))) {
-        if (!psMetadataAddStr(where, PS_LIST_TAIL, "camera", 0, "==", str)) {
+    if ((str = psMetadataLookupStr(&status, config->args, "-inst"))) {
+        if (!psMetadataAddStr(config->where, PS_LIST_TAIL, "camera", 0, "==", str)) {
             psError(PS_ERR_UNKNOWN, false, "failed to add item camera");
-            psFree(where);
             exit(EXIT_FAILURE);
         }
@@ -160,8 +156,7 @@
     addWhereStr(telescope);
     addWhereStr(exp_type);
-    if ((n = psMetadataLookupS32(&status, argSet, "-imfiles"))) {
-        if (!psMetadataAddS32(where, PS_LIST_TAIL, "imfiles", 0, "==", n)) {
+    if ((n = psMetadataLookupS32(&status, config->args, "-imfiles"))) {
+        if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "imfiles", 0, "==", n)) {
             psError(PS_ERR_UNKNOWN, false, "failed to add item imfiles");
-            psFree(where);
             exit(EXIT_FAILURE);
         }
@@ -170,20 +165,16 @@
     addWhereStr(stats);
     addWhereStr(recipe);
-    if ((n = psMetadataLookupS32(&status, argSet, "-p1_version"))) {
-        if (!psMetadataAddS32(where, PS_LIST_TAIL, "p1_version", 0, "==", n)) {
+    if ((n = psMetadataLookupS32(&status, config->args, "-p1_version"))) {
+        if (!psMetadataAddS32(config->where, PS_LIST_TAIL, "p1_version", 0, "==", n)) {
             psError(PS_ERR_UNKNOWN, false, "failed to add item p1_version");
-            psFree(where);
             exit(EXIT_FAILURE);
         }
     }
 }
-    psFree(argSet);
 
-    if (where->list->n < 1) {
-        psFree(where);
-        where = NULL;
+    if (config->where->list->n < 1) {
+        psFree(config->where);
+        config->where = NULL;
     }
-
-    config->where = where;
 
     // define Database handle, if used
