Index: trunk/ippTools/share/Makefile.am
===================================================================
--- trunk/ippTools/share/Makefile.am	(revision 25784)
+++ trunk/ippTools/share/Makefile.am	(revision 25789)
@@ -4,5 +4,10 @@
 
 dist_pkgdata_DATA = \
+     addtool_donecleanup.sql \
+     addtool_find_cam_id.sql \
      addtool_find_pendingexp.sql \
+     addtool_find_processedexp.sql \
+     addtool_pendingcleanupexp.sql \
+     addtool_pendingcleanuprun.sql \
      addtool_queue_cam_id.sql \
      addtool_reset_faulted_runs.sql \
Index: trunk/ippTools/share/addtool_donecleanup.sql
===================================================================
--- trunk/ippTools/share/addtool_donecleanup.sql	(revision 25789)
+++ trunk/ippTools/share/addtool_donecleanup.sql	(revision 25789)
@@ -0,0 +1,5 @@
+SELECT
+    addRun.*
+FROM addRun
+WHERE
+    addRun.state = 'cleaned'
Index: trunk/ippTools/share/addtool_find_cam_id.sql
===================================================================
--- trunk/ippTools/share/addtool_find_cam_id.sql	(revision 25789)
+++ trunk/ippTools/share/addtool_find_cam_id.sql	(revision 25789)
@@ -0,0 +1,9 @@
+SELECT
+    camRun.*
+FROM camRun
+JOIN chipRun
+    USING(chip_id)
+JOIN rawExp
+    USING(exp_id)
+WHERE
+    camRun.state = 'full'
Index: trunk/ippTools/share/addtool_find_pendingexp.sql
===================================================================
--- trunk/ippTools/share/addtool_find_pendingexp.sql	(revision 25784)
+++ trunk/ippTools/share/addtool_find_pendingexp.sql	(revision 25789)
@@ -12,8 +12,6 @@
 JOIN chipRun
     USING(chip_id)
-JOIN chipProcessedImfile
-    USING(chip_id)
 JOIN rawExp
-    ON chipRun.exp_id = rawExp.exp_id
+    USING(exp_id)
 LEFT JOIN addProcessedExp
     USING(add_id)
Index: trunk/ippTools/share/addtool_find_processedexp.sql
===================================================================
--- trunk/ippTools/share/addtool_find_processedexp.sql	(revision 25789)
+++ trunk/ippTools/share/addtool_find_processedexp.sql	(revision 25789)
@@ -0,0 +1,10 @@
+SELECT
+    addProcessedExp.*,
+    addRun.workdir
+FROM addRun
+JOIN camProcessedExp
+    USING(cam_id)
+JOIN chipRun
+    USING(chip_id)
+JOIN rawExp
+    ON chipRun.exp_id = rawExp.exp_id
Index: trunk/ippTools/share/addtool_pendingcleanupexp.sql
===================================================================
--- trunk/ippTools/share/addtool_pendingcleanupexp.sql	(revision 25789)
+++ trunk/ippTools/share/addtool_pendingcleanupexp.sql	(revision 25789)
@@ -0,0 +1,12 @@
+SELECT
+    addProcessedExp.*,
+    addRun.state,
+    addRun.workdir,
+    addRun.label,
+    addRun.dvodb,
+FROM addRun
+JOIN addProcessedExp
+    USING(add_id)
+WHERE
+    (addRun.state = 'goto_cleaned' OR addRun.state = 'goto_purged' OR addRun.state = 'goto_scrubbed')
+
Index: trunk/ippTools/share/addtool_pendingcleanuprun.sql
===================================================================
--- trunk/ippTools/share/addtool_pendingcleanuprun.sql	(revision 25789)
+++ trunk/ippTools/share/addtool_pendingcleanuprun.sql	(revision 25789)
@@ -0,0 +1,13 @@
+SELECT
+    addRun.add_id,
+    rawExp.camera,
+    addRun.state
+FROM addRun
+JOIN camRun
+USING (cam_id)
+JOIN chipRun
+USING (chip_id)
+JOIN rawExp 
+USING (exp_id)
+WHERE
+    (addRun.state = 'goto_cleaned' OR addRun.state = 'goto_purged' OR addRun.state = 'goto_scrubbed')
Index: trunk/ippTools/src/addtool.c
===================================================================
--- trunk/ippTools/src/addtool.c	(revision 25784)
+++ trunk/ippTools/src/addtool.c	(revision 25789)
@@ -106,7 +106,8 @@
 
     psMetadata *where = psMetadataAlloc();
-    pxaddGetSearchArgs (config, where);
-    pxAddLabelSearchArgs (config, where, "-label", "addRun.label", "==");
-    PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction", "==");
+    pxcamGetSearchArgs (config, where);
+    PXOPT_COPY_S64(config->args, where,  "-cam_id",    "camRun.cam_id", "==");
+    pxAddLabelSearchArgs (config, where, "-label",     "camRun.label", "==");
+    PXOPT_COPY_STR(config->args, where,  "-reduction", "camRun.reduction", "==");
 
     if (!psListLength(where->list) &&
@@ -121,4 +122,6 @@
     PXOPT_LOOKUP_STR(reduction, config->args, "-set_reduction", false, false);
     PXOPT_LOOKUP_STR(dvodb, config->args, "-set_dvodb", false, false);
+    PXOPT_LOOKUP_BOOL(pretend, config->args, "-pretend", false);
+    PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false);
 
     // find the cam_id of all the exposures that we want to queue up.
@@ -130,5 +133,5 @@
     }
 
-    // use psDBGenerateWhereSQL because the SQL yields an intermediate table
+    // use psDBGenerateWhereConditionSQL because the SQL ends in a WHERE
     if (where && psListLength(where->list)) {
         psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
@@ -136,5 +139,4 @@
         psFree(whereClause);
     }
-
     psFree(where);
 
@@ -153,4 +155,15 @@
     if (!psArrayLength(output)) {
         psTrace("addtool", PS_LOG_INFO, "no rows found");
+        psFree(output);
+        return true;
+    }
+
+    if (pretend) {
+        // negative simple so the default is true
+        if (!ippdbPrintMetadatas(stdout, output, "addRun", !simple)) {
+            psError(PS_ERR_UNKNOWN, false, "failed to print array");
+            psFree(output);
+            return false;
+        }
         psFree(output);
         return true;
@@ -175,5 +188,5 @@
         psMetadata *md = output->data[i];
 
-        addRunRow *row = addRunObjectFromMetadata(md);
+        camRunRow *row = camRunObjectFromMetadata(md);
         if (!row) {
             psError(PS_ERR_UNKNOWN, false, "failed to convert metadata into addRun");
@@ -218,6 +231,8 @@
 
     psMetadata *where = psMetadataAlloc();
-    pxaddGetSearchArgs (config, where);
     PXOPT_COPY_S64(config->args, where, "-add_id",    "addRun.add_id", "==");
+    PXOPT_COPY_S64(config->args, where, "-cam_id",    "camRun.cam_id", "==");
+    pxcamGetSearchArgs (config, where); // most search arguments based on camera
+
     PXOPT_COPY_STR(config->args, where, "-label",     "addRun.label", "==");
     PXOPT_COPY_STR(config->args, where, "-state",     "addRun.state", "==");
@@ -267,6 +282,7 @@
 
     psMetadata *where = psMetadataAlloc();
-    pxaddGetSearchArgs (config, where);
     PXOPT_COPY_S64(config->args, where, "-add_id",    "addRun.add_id", "==");
+    PXOPT_COPY_S64(config->args, where, "-cam_id",    "camRun.cam_id", "==");
+    pxcamGetSearchArgs (config, where);
     pxAddLabelSearchArgs (config, where, "-label", "addRun.label", "==");
     PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction", "==");
@@ -325,62 +341,4 @@
 }
 
-/* static bool pendingimfileMode(pxConfig *config) */
-/* { */
-/*     PS_ASSERT_PTR_NON_NULL(config, false); */
-
-/*     psMetadata *where = psMetadataAlloc(); */
-/*     pxaddGetSearchArgs (config, where); */
-/*     PXOPT_COPY_S64(config->args, where, "-add_id",    "addRun.add_id",                "=="); */
-/*     pxAddLabelSearchArgs (config, where, "-label",    "addRun.label",                 "=="); */
-/*     PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction",             "=="); */
-/*     PXOPT_COPY_S64(config->args, where, "-chip_id",   "addRun.chip_id",              "=="); */
-/*     PXOPT_COPY_STR(config->args, where, "-class_id",  "addProcessedExp.class_id", "=="); */
-
-/*     PXOPT_LOOKUP_BOOL(simple, config->args, "-simple", false); */
-
-/*     psString query = pxDataGet("addtool_find_pendingimfile.sql"); */
-/*     if (!query) { */
-/*         psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement"); */
-/*         return false; */
-/*     } */
-
-/*     // use psDBGenerateWhereSQL because the SQL yields an intermediate table */
-/*     if (psListLength(where->list)) { */
-/*         psString whereClause = psDBGenerateWhereConditionSQL(where, NULL); */
-/*         psStringAppend(&query, " AND %s", whereClause); */
-/*         psFree(whereClause); */
-/*     } */
-/*     psFree(where); */
-
-/*     if (!p_psDBRunQuery(config->dbh, query)) { */
-/*         psError(PS_ERR_UNKNOWN, false, "database error"); */
-/*         psFree(query); */
-/*         return false; */
-/*     } */
-/*     psFree(query); */
-
-/*     psArray *output = p_psDBFetchResult(config->dbh); */
-/*     if (!output) { */
-/*         psError(PS_ERR_UNKNOWN, false, "database error"); */
-/*         return false; */
-/*     } */
-/*     if (!psArrayLength(output)) { */
-/*         psTrace("addtool", PS_LOG_INFO, "no rows found"); */
-/*         psFree(output); */
-/*         return true; */
-/*     } */
-
-/*     // negate simple so the default is true */
-/*     if (!ippdbPrintMetadatas(stdout, output, "addProcessedExp", !simple)) { */
-/*         psError(PS_ERR_UNKNOWN, false, "failed to print array"); */
-/*         psFree(output); */
-/*         return false; */
-/*     } */
-
-/*     psFree(output); */
-
-/*     return true; */
-/* } */
-
 static bool addprocessedexpMode(pxConfig *config)
 {
@@ -392,9 +350,6 @@
     // optional
     PXOPT_LOOKUP_F32(dtime_addstar, config->args,  "-dtime_addstar", false, false);
-
     PXOPT_LOOKUP_S32(n_stars, config->args,        "-n_stars", false, false);
-
     PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false);
-
     PXOPT_LOOKUP_S64(magicked, config->args, "-magicked", false, false);
 
@@ -469,38 +424,5 @@
         return false;
     }
-
-    // NULL for end_stage means go as far as possible
-    // EAM : skip here if fault != 0
-    // Also, we can run fake even if tess_id is not defined
-/*     if (fault || (pendingRow->end_stage && psStrcasestr(pendingRow->end_stage, "add"))) { */
-/*         psFree(row); */
-/*         psFree(pendingRow); */
-/*         if (!psDBCommit(config->dbh)) { */
-/*             psError(PS_ERR_UNKNOWN, false, "database error"); */
-/*             return false; */
-/*         } */
-/*         return true; */
-/*     } */
     psFree(row);
-    // else continue on...
-
-/*     if (!pxfakeQueueByAddID(config, */
-/*             pendingRow->add_id, */
-/*             pendingRow->workdir, */
-/*             pendingRow->label, */
-/*             pendingRow->reduction, */
-/*             pendingRow->expgroup, */
-/*             pendingRow->dvodb, */
-/*             pendingRow->tess_id, */
-/*             pendingRow->end_stage */
-/*     )) { */
-/*         // rollback */
-/*         if (!psDBRollback(config->dbh)) { */
-/*             psError(PS_ERR_UNKNOWN, false, "database error"); */
-/*         } */
-/*         psError(PS_ERR_UNKNOWN, false, "failed to queue new fakeRun"); */
-/*         psFree(pendingRow); */
-/*         return false; */
-/*     } */
     psFree(pendingRow);
 
@@ -524,6 +446,7 @@
     // generate restrictions
     psMetadata *where = psMetadataAlloc();
-    pxaddGetSearchArgs (config, where);
     PXOPT_COPY_S64(config->args, where, "-add_id",    "addRun.add_id",    "==");
+    PXOPT_COPY_S64(config->args, where, "-cam_id",    "camRun.cam_id",    "==");
+    pxcamGetSearchArgs (config, where);
     pxAddLabelSearchArgs (config, where, "-label",    "addRun.label",     "==");
     PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction", "==");
@@ -613,9 +536,9 @@
 
     psMetadata *where = psMetadataAlloc();
-    pxaddGetSearchArgs (config, where);
     PXOPT_COPY_S64(config->args, where, "-add_id",    "addRun.add_id",         "==");
+    PXOPT_COPY_S64(config->args, where, "-cam_id",    "camRun.cam_id",         "==");
+    pxcamGetSearchArgs (config, where);
     pxAddLabelSearchArgs (config, where, "-label",    "addRun.label",     "==");
     PXOPT_COPY_STR(config->args, where, "-reduction", "addRun.reduction",      "==");
-/*     PXOPT_COPY_S16(config->args, where, "-fault", "addProcessedExp.fault", "=="); */
 
     if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) {
@@ -710,6 +633,4 @@
     PXOPT_COPY_S64(config->args, where, "-add_id",   "add_id",   "==");
     PXOPT_COPY_S64(config->args, where, "-cam_id",  "cam_id",  "==");
-/*     PXOPT_COPY_STR(config->args, where, "-class",    "class",    "=="); */
-/*     PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "=="); */
 
     if (!pxSetFaultCode(config->dbh, "addProcessedExp", where, fault)) {
@@ -776,5 +697,4 @@
     return true;
 }
-
 
 static bool unblockMode(pxConfig *config)
Index: trunk/ippTools/src/addtoolConfig.c
===================================================================
--- trunk/ippTools/src/addtoolConfig.c	(revision 25784)
+++ trunk/ippTools/src/addtoolConfig.c	(revision 25789)
@@ -48,10 +48,9 @@
 
     // -definebyquery
-    // XXX need to allow multiple chip_ids
-    // XXX need to allow multiple exp_ids
     psMetadata *definebyqueryArgs = psMetadataAlloc();
+    psMetadataAddS64(definebyqueryArgs, PS_LIST_TAIL, "-cam_id",             0, "search by cam_id", 0);
     pxcamSetSearchArgs(definebyqueryArgs);
-    psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by chipRun label", NULL);
-    psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-reduction",          0, "search by chipRun reduction class", NULL);
+    psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by camRun label", NULL);
+    psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-reduction",          0, "search by camRun reduction class", NULL);
 
     psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_workdir",        0, "define workdir", NULL);
@@ -59,45 +58,43 @@
     psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_reduction",      0, "define reduction class", NULL);
     psMetadataAddStr(definebyqueryArgs, PS_LIST_TAIL, "-set_dvodb",          0, "define DVO db", NULL);
+    psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-pretend",           0, "do not actually modify the database", false);
     psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-all",               0, "allow everything to be queued without search terms", false);
+    psMetadataAddBool(definebyqueryArgs, PS_LIST_TAIL, "-simple",            0, "use the simple output format", false);
 
     // -updaterun
-    // XXX need to allow multiple add_ids
-    // XXX need to allow multiple chip_ids
-    // XXX need to allow multiple exp_ids
     psMetadata *updaterunArgs = psMetadataAlloc();
+    psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-add_id",                 0, "search by add_id", 0);
+    psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-cam_id",                 0, "search by cam_id", 0);
     pxcamSetSearchArgs(updaterunArgs);
-    psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-add_id",             0, "search by add_id", 0);
-    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 		 0, "search by camRun label", NULL);
-    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 		 0, "search by camRun state", NULL);
-    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-reduction",          0, "search by camRun reduction class", NULL);
-    psMetadataAddBool(updaterunArgs, PS_LIST_TAIL, "-all",               0, "allow everything to be queued without search terms", false);
-    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state",          0, "set state", NULL);
-    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label",          0, "set label", NULL);
+    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label", 		     0, "search by addRun label", NULL);
+    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state", 		     0, "search by addRun state", NULL);
+    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-reduction",              0, "search by addRun reduction class", NULL);
+    psMetadataAddBool(updaterunArgs, PS_LIST_TAIL, "-all",                   0, "allow everything to be queued without search terms", false);
+    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state",              0, "set state", NULL);
+    psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label",              0, "set label", NULL);
 
     // -pendingexp
     psMetadata *pendingexpArgs = psMetadataAlloc();
-    pxcamSetSearchArgs(pendingexpArgs);
     psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-add_id",            0, "search by add_id", 0);
     psMetadataAddS64(pendingexpArgs, PS_LIST_TAIL, "-cam_id",            0, "search by cam_id", 0);
-    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by camRun label", NULL);
-    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-reduction",         0, "search by camRun reduction class", NULL);
+    pxcamSetSearchArgs(pendingexpArgs);
+    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by addRun label", NULL);
+    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-reduction",         0, "search by addRun reduction class", NULL);
     psMetadataAddU64(pendingexpArgs, PS_LIST_TAIL, "-limit",             0, "limit result set to N items", 0);
     psMetadataAddBool(pendingexpArgs, PS_LIST_TAIL, "-simple",           0, "use the simple output format", false);
-
-    // XXX is this used? psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-class",    0,            "search by class", NULL);
 
     // -addprocessedexp
     psMetadata *addprocessedexpArgs = psMetadataAlloc();
     psMetadataAddS64(addprocessedexpArgs, PS_LIST_TAIL, "-add_id", 0,            "define addtool ID (required)", 0);
-
     psMetadataAddF32(addprocessedexpArgs, PS_LIST_TAIL, "-dtime_addstar", 0, "define elapsed time for DVO insertion (seconds)", NAN);
     psMetadataAddS32(addprocessedexpArgs, PS_LIST_TAIL, "-n_stars", 0,            "define number of stars", 0);
-
     psMetadataAddStr(addprocessedexpArgs, PS_LIST_TAIL, "-path_base", 0,            "define base output location", NULL);
     psMetadataAddS64(addprocessedexpArgs, PS_LIST_TAIL, "-magicked", 0,             "set magicked", 0);
+
     // -processedexp
     psMetadata *processedexpArgs = psMetadataAlloc();
+    psMetadataAddS64(processedexpArgs, PS_LIST_TAIL, "-add_id",   0,            "search by add_id", 0);
+    psMetadataAddS64(processedexpArgs, PS_LIST_TAIL, "-cam_id",   0,            "search by cam_id", 0);
     pxcamSetSearchArgs(processedexpArgs);
-    psMetadataAddS64(processedexpArgs, PS_LIST_TAIL, "-add_id",   0,            "search by add_id", 0);
     psMetadataAddStr(processedexpArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "search by addRun label", NULL);
     psMetadataAddStr(processedexpArgs, PS_LIST_TAIL, "-reduction",0,            "search by addRun reduction class", NULL);
@@ -106,13 +103,10 @@
     psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-all",     0,            "list everything without restriction", false);
     psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-simple",  0,            "use the simple output format", false);
-/*     psMetadataAddBool(processedexpArgs, PS_LIST_TAIL, "-faulted", 0,            "only return imfiles with a fault status set", false); */
 
     // -revertprocessedexp
-    // XXX need to allow multiple add_ids
-    // XXX need to allow multiple chip_ids
-    // XXX need to allow multiple exp_ids
     psMetadata *revertprocessedexpArgs = psMetadataAlloc();
+    psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-add_id",   0,            "search by add_id", 0);
+    psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-cam_id",   0,            "search by cam_id", 0);
     pxcamSetSearchArgs(revertprocessedexpArgs);
-    psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-add_id",   0,            "search by add_id", 0);
     psMetadataAddStr(revertprocessedexpArgs, PS_LIST_TAIL, "-label",    PS_META_DUPLICATE_OK, "search by addRun label", NULL);
     psMetadataAddStr(revertprocessedexpArgs, PS_LIST_TAIL, "-reduction",0,            "search by addRun reduction class", NULL);
@@ -121,5 +115,4 @@
 
     // -updateprocessedexp
-    // XXX allow full search options?
     psMetadata *updateprocessedexpArgs = psMetadataAlloc();
     psMetadataAddS64(updateprocessedexpArgs, PS_LIST_TAIL, "-add_id", 0,            "search by addtool ID", 0);
@@ -139,5 +132,4 @@
 
     // -pendingcleanuprun
-    // XXX allow full search options?
     psMetadata *pendingcleanuprunArgs = psMetadataAlloc();
     psMetadataAddStr(pendingcleanuprunArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "list blocks for specified label", NULL);
@@ -146,5 +138,4 @@
 
     // -pendingcleanupexp
-    // XXX allow full search options?
     psMetadata *pendingcleanupexpArgs = psMetadataAlloc();
     psMetadataAddStr(pendingcleanupexpArgs, PS_LIST_TAIL, "-label", PS_META_DUPLICATE_OK, "list blocks for specified label", NULL);
Index: trunk/ippTools/src/pxadd.c
===================================================================
--- trunk/ippTools/src/pxadd.c	(revision 25784)
+++ trunk/ippTools/src/pxadd.c	(revision 25789)
@@ -28,97 +28,4 @@
 #include "pxtools.h"
 #include "pxadd.h"
-
-bool pxaddSetSearchArgs (psMetadata *md) {
-
-    psMetadataAddS64(md,  PS_LIST_TAIL, "-add_id",            0, "search by add_id", 0);
-    psMetadataAddS64(md,  PS_LIST_TAIL, "-cam_id",             0, "search by cam_id", 0);
-
-/*     psMetadataAddStr(md,  PS_LIST_TAIL, "-exp_name",           0, "search by exp_name", NULL); */
-/*     psMetadataAddStr(md,  PS_LIST_TAIL, "-inst",               0, "search for camera", NULL); */
-/*     psMetadataAddStr(md,  PS_LIST_TAIL, "-telescope",          0, "search for telescope", NULL); */
-/*     psMetadataAddTime(md, PS_LIST_TAIL, "-dateobs_begin",      0, "search for exposures by time (>=)", NULL); */
-/*     psMetadataAddTime(md, PS_LIST_TAIL, "-dateobs_end",        0, "search for exposures by time (<)", NULL); */
-/*     psMetadataAddStr(md,  PS_LIST_TAIL, "-exp_tag",            0, "search by exp_tag", NULL); */
-/*     psMetadataAddStr(md,  PS_LIST_TAIL, "-exp_type",           0, "search by exp_type", NULL); */
-/*     psMetadataAddStr(md,  PS_LIST_TAIL, "-comment",            0, "search by comment", NULL); */
-/*     psMetadataAddStr(md,  PS_LIST_TAIL, "-filelevel",          0, "search by filelevel", NULL); */
-/*     psMetadataAddStr(md,  PS_LIST_TAIL, "-filter",             0, "search for filter", NULL); */
-/*     psMetadataAddF64(md,  PS_LIST_TAIL, "-airmass_min",        0, "define min airmass", NAN); */
-/*     psMetadataAddF64(md,  PS_LIST_TAIL, "-airmass_max",        0, "define max airmass", NAN); */
-/*     psMetadataAddF64(md,  PS_LIST_TAIL, "-ra_min",             0, "define min RA (degrees) ", NAN); */
-/*     psMetadataAddF64(md,  PS_LIST_TAIL, "-ra_max",             0, "define max RA (degrees) ", NAN); */
-/*     psMetadataAddF64(md,  PS_LIST_TAIL, "-decl_min",           0, "define min DEC (degrees)", NAN); */
-/*     psMetadataAddF64(md,  PS_LIST_TAIL, "-decl_max",           0, "define max DEC (degrees)", NAN); */
-/*     psMetadataAddF32(md,  PS_LIST_TAIL, "-exp_time_min",       0, "define min exposure time", NAN); */
-/*     psMetadataAddF32(md,  PS_LIST_TAIL, "-exp_time_max",       0, "define max exposure time", NAN); */
-/*     psMetadataAddF32(md,  PS_LIST_TAIL, "-sat_pixel_frac_min", 0, "define max fraction of saturated pixels", NAN); */
-/*     psMetadataAddF32(md,  PS_LIST_TAIL, "-sat_pixel_frac_max", 0, "define max fraction of saturated pixels", NAN); */
-/*     psMetadataAddF64(md,  PS_LIST_TAIL, "-bg_min",             0, "define min background", NAN); */
-/*     psMetadataAddF64(md,  PS_LIST_TAIL, "-bg_max",             0, "define max background", NAN); */
-/*     psMetadataAddF64(md,  PS_LIST_TAIL, "-bg_stdev_min",       0, "define min background standard deviation", NAN); */
-/*     psMetadataAddF64(md,  PS_LIST_TAIL, "-bg_stdev_max",       0, "define max background standard deviation", NAN); */
-/*     psMetadataAddF64(md,  PS_LIST_TAIL, "-bg_mean_stdev_min",  0, "define min background mean standard deviation (across imfiles)", NAN); */
-/*     psMetadataAddF64(md,  PS_LIST_TAIL, "-bg_mean_stdev_max",  0, "define max background mean standard deviation (across imfiles)", NAN); */
-/*     psMetadataAddF64(md,  PS_LIST_TAIL, "-alt_min",            0, "define min altitude", NAN); */
-/*     psMetadataAddF64(md,  PS_LIST_TAIL, "-alt_max",            0, "define max altitude", NAN); */
-/*     psMetadataAddF64(md,  PS_LIST_TAIL, "-az_min",             0, "define min azimuth ", NAN); */
-/*     psMetadataAddF64(md,  PS_LIST_TAIL, "-az_max",             0, "define max azimuth ", NAN); */
-/*     psMetadataAddF32(md,  PS_LIST_TAIL, "-ccd_temp_min",       0, "define min ccd tempature", NAN); */
-/*     psMetadataAddF32(md,  PS_LIST_TAIL, "-ccd_temp_max",       0, "define max ccd tempature", NAN); */
-/*     psMetadataAddF64(md,  PS_LIST_TAIL, "-posang_min",         0, "define min rotator position angle", NAN); */
-/*     psMetadataAddF64(md,  PS_LIST_TAIL, "-posang_max",         0, "define max rotator position angle", NAN); */
-/*     psMetadataAddStr(md,  PS_LIST_TAIL, "-object",             0, "search by exposure object", NULL); */
-/*     psMetadataAddF32(md,  PS_LIST_TAIL, "-sun_angle_min",      0, "define min solar angle", NAN); */
-/*     psMetadataAddF32(md,  PS_LIST_TAIL, "-sun_angle_max",      0, "define max solar angle", NAN); */
-
-    return true;
-}
-
-bool pxaddGetSearchArgs (pxConfig *config, psMetadata *where) {
-
-    PXOPT_COPY_S64(config->args,     where, "-add_id",             "addRun.add_id",        "==");
-/*     PXOPT_COPY_S64(config->args,     where, "-cam_id",             "camRun.cam_id",        "=="); */
-/*     PXOPT_COPY_S64(config->args,   where, "-chip_id",            "chipRun.chip_id", 	 "=="); */
-/*     PXOPT_COPY_S64(config->args,   where, "-exp_id",             "rawExp.exp_id",   	 "=="); */
-/*     PXOPT_COPY_STR(config->args,   where, "-exp_name",           "rawExp.exp_name", 	 "=="); */
-/*     PXOPT_COPY_STR(config->args,   where, "-inst",               "rawExp.camera",   	 "=="); */
-/*     PXOPT_COPY_STR(config->args,   where, "-telescope",          "rawExp.telescope",	 "=="); */
-/*     PXOPT_COPY_TIME(config->args,  where, "-dateobs_begin",      "rawExp.dateobs",  	 ">="); */
-/*     PXOPT_COPY_TIME(config->args,  where, "-dateobs_end",        "rawExp.dateobs",  	 "<="); */
-/*     PXOPT_COPY_STR(config->args,   where, "-exp_tag",            "rawExp.exp_tag",  	 "=="); */
-/*     PXOPT_COPY_STR(config->args,   where, "-exp_type",           "rawExp.exp_type", 	 "=="); */
-/*     PXOPT_COPY_STR(config->args,   where, "-comment",            "rawExp.comment",  	 "LIKE"); */
-/*     PXOPT_COPY_STR(config->args,   where, "-filelevel",          "rawExp.filelevel",	 "=="); */
-/*     PXOPT_COPY_STR(config->args,   where, "-filter",             "rawExp.filter",         "=="); */
-/*     PXOPT_COPY_F64(config->args,   where, "-airmass_min",        "rawExp.airmass",        ">="); */
-/*     PXOPT_COPY_F64(config->args,   where, "-airmass_max",        "rawExp.airmass",        "<"); */
-/*     PXOPT_COPY_RADEC(config->args, where, "-ra_min",             "rawExp.ra",             ">="); */
-/*     PXOPT_COPY_RADEC(config->args, where, "-ra_max",             "rawExp.ra",             "<"); */
-/*     PXOPT_COPY_RADEC(config->args, where, "-decl_min",           "rawExp.decl",           ">="); */
-/*     PXOPT_COPY_RADEC(config->args, where, "-decl_max",           "rawExp.decl",           "<"); */
-/*     PXOPT_COPY_F32(config->args,   where, "-exp_time_min",       "rawExp.exp_time",       ">="); */
-/*     PXOPT_COPY_F32(config->args,   where, "-exp_time_max",       "rawExp.exp_time",       "<"); */
-/*     PXOPT_COPY_F32(config->args,   where, "-sat_pixel_frac_min", "rawExp.sat_pixel_frac", ">="); */
-/*     PXOPT_COPY_F32(config->args,   where, "-sat_pixel_frac_max", "rawExp.sat_pixel_frac", "<"); */
-/*     PXOPT_COPY_F64(config->args,   where, "-bg_min",             "rawExp.bg",             ">="); */
-/*     PXOPT_COPY_F64(config->args,   where, "-bg_max",             "rawExp.bg",             "<"); */
-/*     PXOPT_COPY_F64(config->args,   where, "-bg_stdev_min",       "rawExp.bg_stdev",       ">="); */
-/*     PXOPT_COPY_F64(config->args,   where, "-bg_stdev_max",       "rawExp.bg_stdev",       "<"); */
-/*     PXOPT_COPY_F64(config->args,   where, "-bg_mean_stdev_min",  "rawExp.bg_mean_stdev",  ">="); */
-/*     PXOPT_COPY_F64(config->args,   where, "-bg_mean_stdev_max",  "rawExp.bg_mean_stdev",  "<"); */
-/*     PXOPT_COPY_F64(config->args,   where, "-alt_min",            "rawExp.alt",            ">="); */
-/*     PXOPT_COPY_F64(config->args,   where, "-alt_max",            "rawExp.alt",            "<"); */
-/*     PXOPT_COPY_F64(config->args,   where, "-az_min",             "rawExp.az",             ">="); */
-/*     PXOPT_COPY_F64(config->args,   where, "-az_max",             "rawExp.az",             "<"); */
-/*     PXOPT_COPY_F32(config->args,   where, "-ccd_temp_min",       "rawExp.ccd_temp",       ">="); */
-/*     PXOPT_COPY_F32(config->args,   where, "-ccd_temp_max",       "rawExp.ccd_temp",       "<"); */
-/*     PXOPT_COPY_F64(config->args,   where, "-posang_min",         "rawExp.posang",         ">="); */
-/*     PXOPT_COPY_F64(config->args,   where, "-posang_max",         "rawExp.posang",         "<"); */
-/*     PXOPT_COPY_STR(config->args,   where, "-object",             "rawExp.object",         "=="); */
-/*     PXOPT_COPY_F32(config->args,   where, "-sun_angle_min",      "rawExp.sun_angle",      ">="); */
-/*     PXOPT_COPY_F32(config->args,   where, "-sun_angle_max",      "rawExp.sun_angle",      "<"); */
-
-    return true;
-}
 
 bool pxaddRunSetState(pxConfig *config, psS64 add_id, const char *state, psS64 magicked)
@@ -236,8 +143,8 @@
         }
     }
-    //    fprintf(stderr,"%s",query);
+
     // queue the exp
-    // XXX chip_id is being cast here work around psS64 have a different type
-    // different on 32/64
+    // Note: cam_id is being cast here work around psS64 have a different type different
+    // on 32/64
     if (!p_psDBRunQueryF(config->dbh, query,
 			 "new", // state
Index: trunk/ippTools/src/pxadd.h
===================================================================
--- trunk/ippTools/src/pxadd.h	(revision 25784)
+++ trunk/ippTools/src/pxadd.h	(revision 25789)
@@ -30,7 +30,4 @@
 bool pxaddRunSetLabelByQuery(pxConfig *config, psMetadata *where, const char *label);
 
-bool pxaddSetSearchArgs (psMetadata *md);
-bool pxaddGetSearchArgs (pxConfig *config, psMetadata *where);
-
 // Likely BROKEN
 bool pxaddQueueByCamID(pxConfig *config,
