Index: trunk/ippTools/src/dettool.c
===================================================================
--- trunk/ippTools/src/dettool.c	(revision 13977)
+++ trunk/ippTools/src/dettool.c	(revision 14023)
@@ -173,7 +173,7 @@
         " FROM rawExp"
         " LEFT JOIN detInputExp"
-        "   ON rawExp.exp_tag = detInputExp.exp_tag"
+        "   ON rawExp.exp_id = detInputExp.exp_id"
         " WHERE"
-        "    detInputExp.exp_tag IS NULL"
+        "    detInputExp.exp_id IS NULL"
         "    AND rawExp.obstype != 'object'"
     );
@@ -461,14 +461,14 @@
     }
 
-    // we have to support multipe exp_tags
-    psMetadataItem *item = psMetadataLookup(config->args, "-exp_tag");
+    // we have to support multipe exp_ids
+    psMetadataItem *item = psMetadataLookup(config->args, "-exp_id");
     if (!item) {
         // this shouldn't actually happen when using psArgs
-        psError(PS_ERR_UNKNOWN, true, "-exp_tag is required");
+        psError(PS_ERR_UNKNOWN, true, "-exp_id is required");
         return false;
     }
     psMetadata *where = psMetadataAlloc();
 
-    // make sure that -exp_tag was parsed correctly
+    // make sure that -exp_id was parsed correctly
     // XXX this can be removed someday
     if (item->type == PS_DATA_METADATA_MULTI) {
@@ -476,17 +476,17 @@
         psMetadataItem *mItem = NULL;
         while ((mItem = psListGetAndIncrement(iter))) {
-            psString exp_tag = mItem->data.V;
-            // if exp_tag is NULL then it means that -exp_tag has not been
+            psString exp_id = mItem->data.V;
+            // if exp_id is NULL then it means that -exp_id has not been
             // specified
-            if (!exp_tag) {
+            if (!exp_id) {
                 psError(PS_ERR_UNKNOWN, true,
-                        "at least one -exp_tag is required");
+                        "at least one -exp_id is required");
                 psFree(where);
                 return false;
             }
 
-            if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag",
-                 PS_META_DUPLICATE_OK, "==", exp_tag)) {
-                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
+            if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id",
+                 PS_META_DUPLICATE_OK, "==", exp_id)) {
+                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
                 psFree(iter);
                 psFree(where);
@@ -496,5 +496,5 @@
         psFree(iter);
     } else {
-        psAbort(                "-exp_tag was not parsed correctly (this should not happen");
+        psAbort(                "-exp_id was not parsed correctly (this should not happen");
     }
 
@@ -504,5 +504,5 @@
     }
 
-    // check that the specified exp_tags actually exist
+    // check that the specified exp_ids actually exist
     psArray *detrendExps = rawExpSelectRowObjects(config->dbh, where, 0);
     psFree(where);
@@ -512,7 +512,7 @@
     }
 
-    // we should have one rawExp row per exp_tag specified
+    // we should have one rawExp row per exp_id specified
     if (psListLength(item->data.list) != psArrayLength(detrendExps)) {
-        psAbort(    "an -exp_tag matched more then one rawExp (this should not happen");
+        psAbort(    "an -exp_id matched more then one rawExp (this should not happen");
 
     }
@@ -1768,9 +1768,9 @@
         "       %d,"
         "       0,"
-        "       detResidExp.exp_tag,"
+        "       detResidExp.exp_id,"
         "       detResidExp.accept"
         "   FROM detResidExp"
         "   JOIN rawExp"
-        "       USING(exp_tag)"
+        "       USING(exp_id)"
         "   WHERE det_id = %d"
     );
@@ -1979,5 +1979,5 @@
         det_id,
         iteration,
-        rawExp->exp_tag,
+        rawExp->exp_id,
         true            // use
     );
@@ -1991,5 +1991,5 @@
     // select rawExp.*
     // by:
-    // exp_tag
+    // exp_id
 
     psString query = psStringCopy(
@@ -1997,5 +1997,5 @@
         " FROM detInputExp"
         " JOIN rawExp"
-        " USING(exp_tag)"
+        " USING(exp_id)"
         );
 
@@ -2058,7 +2058,7 @@
             " FROM rawImfile"
             " JOIN detInputExp"
-            "   USING(exp_tag) "
+            "   USING(exp_id) "
             " JOIN rawExp"
-            "   USING(exp_tag) "
+            "   USING(exp_id) "
             " JOIN detRun"
             "   ON detInputExp.det_id = detRun.det_id"
@@ -2130,7 +2130,7 @@
     //
     // det_id is in detInputExp
-    // exp_tag is in detInputExp
+    // exp_id is in detInputExp
     // det_id is not in detProccessedImfile
-    // exp_tag is not in detProccessedImfile
+    // exp_id is not in detProccessedImfile
     // class_is is not in detProccessedImfile
     psString query = psStringCopy(
@@ -2146,10 +2146,10 @@
             "    USING(det_id, iteration)"
             " JOIN rawExp"
-            "    ON detInputExp.exp_tag = rawExp.exp_tag"
+            "    ON detInputExp.exp_id = rawExp.exp_id"
             " JOIN rawImfile"
-            "    ON detInputExp.exp_tag = rawImfile.exp_tag"
+            "    ON detInputExp.exp_id = rawImfile.exp_id"
             " LEFT JOIN detProcessedImfile"
             "   ON detInputExp.det_id = detProcessedImfile.det_id"
-            "   AND rawImfile.exp_tag = detProcessedImfile.exp_tag"
+            "   AND rawImfile.exp_id = detProcessedImfile.exp_id"
             "   AND rawImfile.class_id = detProcessedImfile.class_id"
             " WHERE"
@@ -2157,5 +2157,5 @@
             "   AND detRun.mode = 'master'"
             "   AND detProcessedImfile.det_id IS NULL"
-            "   AND detProcessedImfile.exp_tag IS NULL"
+            "   AND detProcessedImfile.exp_id IS NULL"
             "   AND detProcessedImfile.class_id IS NULL"
         );
@@ -2223,5 +2223,5 @@
     }
 
-    // select exp_tags from detInputExp matching det_idp
+    // select exp_ids from detInputExp matching det_idp
     // where query should be pre-generated
     psArray *detInputExp =
@@ -2232,14 +2232,14 @@
     }
 
-    // generate where query with just the exp_tags
-    psMetadata *where_exp_tags = psMetadataAlloc();
+    // generate where query with just the exp_ids
+    psMetadata *where_exp_ids = psMetadataAlloc();
     for (long i = 0; i < psArrayLength(detInputExp); i++) {
         detInputExpRow *row = detInputExp->data[i];
-        if (!psMetadataAddStr(where_exp_tags, PS_LIST_TAIL, "exp_tag",
-                PS_META_DUPLICATE_OK, "==", row->exp_tag)
+        if (!psMetadataAddS64(where_exp_ids, PS_LIST_TAIL, "exp_id",
+                PS_META_DUPLICATE_OK, "==", row->exp_id)
         ) {
-            psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
+            psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
             psFree(detInputExp);
-            psFree(where_exp_tags);
+            psFree(where_exp_ids);
             return NULL;
         }
@@ -2247,8 +2247,8 @@
     psFree(detInputExp);
 
-    // select rawImfiles with matching exp_tags
+    // select rawImfiles with matching exp_ids
     psArray *rawImfiles =
-        rawImfileSelectRowObjects(config->dbh, where_exp_tags, 0);
-    psFree(where_exp_tags);
+        rawImfileSelectRowObjects(config->dbh, where_exp_ids, 0);
+    psFree(where_exp_ids);
     if (!rawImfiles) {
         psError(PS_ERR_UNKNOWN, false, "no rawImfile rows found");
@@ -2263,5 +2263,5 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    // det_id, exp_tag, class_id, uri, recipe, -bg, -bg_stdev
+    // det_id, exp_id, class_id, uri, recipe, -bg, -bg_stdev
     // are required
     bool status = false;
@@ -2275,11 +2275,11 @@
         return false;
     }
-    psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
-        return false;
-    }
-    if (!exp_tag) {
-        psError(PS_ERR_UNKNOWN, true, "-exp_tag is required");
+    psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
+        return false;
+    }
+    if (!exp_id) {
+        psError(PS_ERR_UNKNOWN, true, "-exp_id is required");
         return false;
     }
@@ -2384,8 +2384,8 @@
     }
 
-    // find the matching rawImfile by exp_tag/class_id
+    // find the matching rawImfile by exp_id/class_id
     psMetadata *where = psMetadataAlloc();
-    if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag", 0, "==", exp_tag)) {
-        psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
+    if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", exp_id)) {
+        psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
         psFree(where);
         return false;
@@ -2415,5 +2415,5 @@
     detProcessedImfileRow *detRow = detProcessedImfileRowAlloc(
         (psS32)atol(det_id),
-        exp_tag,
+        (psS64)atoll(exp_id),
         class_id,
         uri,
@@ -2461,10 +2461,10 @@
     // select detRun.iteration
     // select detRun.det_type
-    // select detProcessedImfile.exp_tag
+    // select detProcessedImfile.exp_id
     // by:
     // find the current iteration bassed on det_id
-    // find all exp_tags in the current det_id/iteration from detInputExp
-    // find all rawImfiles in the current exp_tags
-    // compare to detProcessedImfiles by det_id/exp_tag
+    // find all exp_ids in the current det_id/iteration from detInputExp
+    // find all rawImfiles in the current exp_ids
+    // compare to detProcessedImfiles by det_id/exp_id
     // found how many imfile there are in each class_id
     // and:
@@ -2477,5 +2477,5 @@
         "    iteration,"
         "    det_type,"
-        "    exp_tag,"
+        "    exp_id,"
         "    camera,"
         "    workdir"
@@ -2486,5 +2486,5 @@
         "    detRun.det_type,"
         "    detRun.workdir,"
-        "    detProcessedImfile.exp_tag,"
+        "    detProcessedImfile.exp_id,"
         "    rawExp.camera,"
         "    detProcessedImfile.class_id,"
@@ -2494,14 +2494,14 @@
         "   USING(det_id, iteration)"
         " JOIN rawExp"
-        "   ON detInputExp.exp_tag = rawExp.exp_tag"
+        "   ON detInputExp.exp_id = rawExp.exp_id"
         " JOIN rawImfile"
-        "   ON rawExp.exp_tag = rawImfile.exp_tag"
+        "   ON rawExp.exp_id = rawImfile.exp_id"
         " LEFT JOIN detProcessedImfile"
         "   ON detRun.det_id = detProcessedImfile.det_id"
-        "   AND detInputExp.exp_tag = detProcessedImfile.exp_tag"
+        "   AND detInputExp.exp_id = detProcessedImfile.exp_id"
         "   AND rawImfile.class_id = detProcessedImfile.class_id"
         " LEFT JOIN detProcessedExp"
         "   ON detProcessedImfile.det_id = detProcessedExp.det_id"
-        "   AND detProcessedImfile.exp_tag = detProcessedExp.exp_tag"
+        "   AND detProcessedImfile.exp_id = detProcessedExp.exp_id"
         " WHERE"
         "   detRun.state = 'run'"
@@ -2509,8 +2509,8 @@
         "   AND detProcessedImfile.fault = 0"
         "   AND detProcessedExp.det_id IS NULL"
-        "   AND detProcessedExp.exp_tag IS NULL"
+        "   AND detProcessedExp.exp_id IS NULL"
         "   AND detInputExp.include = 1"
         " GROUP BY"
-        "    rawExp.exp_tag,"
+        "    rawExp.exp_id,"
         "    detRun.det_id"
         " HAVING"
@@ -2579,5 +2579,5 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    // det_id, exp_tag, recip, -bg, -bg_stdev
+    // det_id, exp_id, recip, -bg, -bg_stdev
     // are required
     bool status = false;
@@ -2591,11 +2591,11 @@
         return false;
     }
-    psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
-        return false;
-    }
-    if (!exp_tag) {
-        psError(PS_ERR_UNKNOWN, true, "-exp_tag is required");
+    psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
+        return false;
+    }
+    if (!exp_id) {
+        psError(PS_ERR_UNKNOWN, true, "-exp_id is required");
         return false;
     }
@@ -2693,5 +2693,5 @@
         "    detRun.iteration,"
         "    detRun.det_type,"
-        "    detProcessedImfile.exp_tag"
+        "    detProcessedImfile.exp_id"
         " FROM detRun"
         " JOIN detInputExp"
@@ -2699,13 +2699,13 @@
         "    AND detRun.iteration = detInputExp.iteration"
         " JOIN rawExp"
-        "    ON detInputExp.exp_tag = rawExp.exp_tag"
+        "    ON detInputExp.exp_id = rawExp.exp_id"
         " JOIN detProcessedImfile"
         "    ON detInputExp.det_id = detProcessedImfile.det_id"
-        "    AND detInputExp.exp_tag = detProcessedImfile.exp_tag"
+        "    AND detInputExp.exp_id = detProcessedImfile.exp_id"
         " LEFT JOIN detProcessedExp"
         "    ON detInputExp.det_id = detProcessedExp.det_id"
-        "    AND detProcessedImfile.exp_tag= detProcessedExp.exp_tag"
+        "    AND detProcessedImfile.exp_id= detProcessedExp.exp_id"
         " LEFT JOIN rawImfile"
-        "    ON detInputExp.exp_tag = rawImfile.exp_tag"
+        "    ON detInputExp.exp_id = rawImfile.exp_id"
         "    AND detProcessedImfile.class_id = rawImfile.class_id"
         " WHERE"
@@ -2713,8 +2713,8 @@
         "   AND detRun.mode = 'master'"
         "   AND detProcessedExp.det_id IS NULL"
-        "   AND detProcessedExp.exp_tag IS NULL"
+        "   AND detProcessedExp.exp_id IS NULL"
         "   AND detInputExp.include = 1"
         "   AND detRun.det_id = %s"
-        "   AND detProcessedImfile.exp_tag = '%s'"
+        "   AND detProcessedImfile.exp_id = '%s'"
         " GROUP BY"
         "    detProcessedImfile.class_id,"
@@ -2725,5 +2725,5 @@
         );
 
-    if (!p_psDBRunQuery(config->dbh, query, det_id, exp_tag)) {
+    if (!p_psDBRunQuery(config->dbh, query, det_id, exp_id)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         psFree(query);
@@ -2747,5 +2747,5 @@
     detProcessedExpRow *detRow = detProcessedExpRowAlloc(
         (psS32)atol(det_id),
-        exp_tag,
+        (psS64)atoll(exp_id),
         recipe,
         bg,
@@ -2872,7 +2872,7 @@
     // by:
     // find the current iteration bassed on det_id
-    // find all exp_tags in the current det_id/iteration from detInputExp
-    // find all rawImfiles in the current exp_tags
-    // compare to detProcessedImfiles by det_id/exp_tag
+    // find all exp_ids in the current det_id/iteration from detInputExp
+    // find all rawImfiles in the current exp_ids
+    // compare to detProcessedImfiles by det_id/exp_id
     // found how many imfile there are in each class_id
     // and:
@@ -2895,10 +2895,10 @@
         "    AND detRun.iteration = detInputExp.iteration\n"
         " JOIN rawExp\n"
-        "    ON detInputExp.exp_tag = rawExp.exp_tag\n"
+        "    ON detInputExp.exp_id = rawExp.exp_id\n"
         " JOIN rawImfile\n"
-        "    ON detInputExp.exp_tag = rawImfile.exp_tag\n"
+        "    ON detInputExp.exp_id = rawImfile.exp_id\n"
         " LEFT JOIN detProcessedImfile\n"
         "    ON detInputExp.det_id = detProcessedImfile.det_id\n"
-        "    AND detInputExp.exp_tag = detProcessedImfile.exp_tag\n"
+        "    AND detInputExp.exp_id = detProcessedImfile.exp_id\n"
         "    AND rawImfile.class_id = detProcessedImfile.class_id\n"
         " LEFT JOIN detStackedImfile\n"
@@ -3007,7 +3007,7 @@
         "   ON detRun.det_id = detInputExp.det_id"
         "   AND detRun.iteration = detInputExp.iteration"
-        "   AND detProcessedImfile.exp_tag = detInputExp.exp_tag"
+        "   AND detProcessedImfile.exp_id = detInputExp.exp_id"
         " JOIN rawExp"
-        "   ON rawExp.exp_tag = detProcessedImfile.exp_tag"
+        "   ON rawExp.exp_id = detProcessedImfile.exp_id"
         " WHERE"
     );
@@ -3213,5 +3213,5 @@
     if (!psMetadataAddS32(where, PS_LIST_TAIL, "det_id", 0, "==",
             (psS64)atoll(det_id))) {
-        psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
+        psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
         psFree(where);
         return false;
@@ -3377,5 +3377,5 @@
     // by:
     // find the current iteration bassed on det_id
-    // find all exp_tags in the current det_id/iteration from detInputExp
+    // find all exp_ids in the current det_id/iteration from detInputExp
     // sort to detInputExp.imfiles to find the largest value per det_id/iter
     // compare imfiles to the number of detStackedImfiles by class_id
@@ -3407,5 +3407,5 @@
         "   AND detRun.iteration = detInputExp.iteration"
         " JOIN rawExp"
-        "   ON detInputExp.exp_tag = rawExp.exp_tag"
+        "   ON detInputExp.exp_id = rawExp.exp_id"
         " JOIN detStackedImfile"
         "   ON detInputExp.det_id = detStackedImfile.det_id"
@@ -3423,5 +3423,5 @@
         "   AND detNormalizedStatImfile.class_id IS NULL"
         " GROUP BY"
-        "   rawExp.exp_tag,"
+        "   rawExp.exp_id,"
         "   detRun.iteration,"
         "   detRun.det_id"
@@ -3633,5 +3633,5 @@
         "   USING(det_id, iteration)"
         " JOIN rawExp"
-        "   ON detInputExp.exp_tag = rawExp.exp_tag"
+        "   ON detInputExp.exp_id = rawExp.exp_id"
         " JOIN detNormalizedStatImfile"
         "   ON detStackedImfile.det_id = detNormalizedStatImfile.det_id"
@@ -3774,8 +3774,8 @@
         psMetadata *where = psMetadataAlloc();
         for (long i = 0; i < psArrayLength(inputExps); i++) {
-            if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag",
+            if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id",
                     PS_META_DUPLICATE_OK, "==",
-                    ((detInputExpRow *)inputExps->data[i])->exp_tag)) {
-                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
+                    ((detInputExpRow *)inputExps->data[i])->exp_id)) {
+                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
                 psFree(inputExps);
                 psFree(where);
@@ -3963,10 +3963,10 @@
         "    AND detRun.iteration = detInputExp.iteration"
         " JOIN rawExp"
-        "    ON detInputExp.exp_tag = rawExp.exp_tag"
+        "    ON detInputExp.exp_id = rawExp.exp_id"
         " JOIN detNormalizedImfile"
         "    ON detInputExp.det_id = detNormalizedImfile.det_id"
         "    AND detInputExp.iteration = detNormalizedImfile.iteration"
         " LEFT JOIN rawImfile"
-        "    ON detInputExp.exp_tag = rawImfile.exp_tag"
+        "    ON detInputExp.exp_id = rawImfile.exp_id"
         "    AND detNormalizedImfile.class_id = rawImfile.class_id"
         " LEFT JOIN detNormalizedExp"
@@ -4152,10 +4152,10 @@
         "    AND detRun.iteration = detInputExp.iteration"
         " JOIN rawExp"
-        "    ON detInputExp.exp_tag = rawExp.exp_tag"
+        "    ON detInputExp.exp_id = rawExp.exp_id"
         " JOIN detNormalizedImfile"
         "    ON detInputExp.det_id = detNormalizedImfile.det_id"
         "    AND detInputExp.iteration = detNormalizedImfile.iteration"
         " LEFT JOIN rawImfile"
-        "    ON detInputExp.exp_tag = rawImfile.exp_tag"
+        "    ON detInputExp.exp_id = rawImfile.exp_id"
         "    AND detNormalizedImfile.class_id = rawImfile.class_id"
         " LEFT JOIN detNormalizedExp"
@@ -4437,5 +4437,5 @@
         "   detRun.workdir,\n"
         "   detRun.reduction,\n"
-        "   detProcessedImfile.exp_tag,\n"
+        "   detProcessedImfile.exp_id,\n"
         "   detProcessedImfile.class_id,\n"
         "   detProcessedImfile.uri,\n"
@@ -4446,8 +4446,8 @@
         "   USING(det_id, iteration)\n"
         " JOIN rawExp\n"
-        "   ON detInputExp.exp_tag = rawExp.exp_tag\n"
+        "   ON detInputExp.exp_id = rawExp.exp_id\n"
         " JOIN detProcessedImfile\n"
         "   ON detRun.det_id = detProcessedImfile.det_id\n"
-        "   AND detInputExp.exp_tag = detProcessedImfile.exp_tag\n"
+        "   AND detInputExp.exp_id = detProcessedImfile.exp_id\n"
         " JOIN detNormalizedImfile\n"
         "   ON detRun.det_id = detNormalizedImfile.det_id\n"
@@ -4457,5 +4457,5 @@
         "   ON detRun.det_id = detResidImfile.det_id\n"
         "   AND detRun.iteration = detResidImfile.iteration\n"
-        "   AND detProcessedImfile.exp_tag = detResidImfile.exp_tag\n"
+        "   AND detProcessedImfile.exp_id = detResidImfile.exp_id\n"
         "   AND detProcessedImfile.class_id = detResidImfile.class_id\n"
         " WHERE\n"
@@ -4465,5 +4465,5 @@
         "   AND detResidImfile.det_id IS NULL\n"
         "   AND detResidImfile.iteration IS NULL\n"
-        "   AND detResidImfile.exp_tag IS NULL\n"
+        "   AND detResidImfile.exp_id IS NULL\n"
         "   AND detResidImfile.class_id IS NULL\n"
         " UNION"
@@ -4475,5 +4475,5 @@
         "   detRun.workdir,\n"
         "   detRun.reduction,\n"
-        "   rawImfile.exp_tag,\n"
+        "   rawImfile.exp_id,\n"
         "   rawImfile.class_id,\n"
         "   rawImfile.uri,\n"
@@ -4484,11 +4484,11 @@
         "    USING(det_id, iteration)\n"
         " JOIN rawExp\n"
-        "    ON detInputExp.exp_tag = rawExp.exp_tag\n"
+        "    ON detInputExp.exp_id = rawExp.exp_id\n"
         " JOIN rawImfile\n"
-        "    ON detInputExp.exp_tag = rawImfile.exp_tag\n"
+        "    ON detInputExp.exp_id = rawImfile.exp_id\n"
         " LEFT JOIN detResidImfile\n"
         "   ON detRun.det_id = detResidImfile.det_id\n"
         "   AND detRun.iteration = detResidImfile.iteration\n"
-        "   AND rawImfile.exp_tag = detResidImfile.exp_tag\n"
+        "   AND rawImfile.exp_id = detResidImfile.exp_id\n"
         "   AND rawImfile.class_id = detResidImfile.class_id\n"
         " WHERE\n"
@@ -4497,5 +4497,5 @@
         "   AND detResidImfile.det_id IS NULL\n"
         "   AND detResidImfile.iteration IS NULL\n"
-        "   AND detResidImfile.exp_tag IS NULL\n"
+        "   AND detResidImfile.exp_id IS NULL\n"
         "   AND detResidImfile.class_id IS NULL\n"
         );
@@ -4658,5 +4658,5 @@
 
     // make sure that there is a coresponding entry in detNormalizedImfile
-    // and the exp_tag specified is valid
+    // and the exp_id specified is valid
     // select * from detNormalizedImfile
     // by det_id, iteration, class_id
@@ -4674,5 +4674,5 @@
         "   ON detRun.det_id = detResidImfile.det_id\n"
         "   AND detRun.iteration = detResidImfile.iteration\n"
-        "   AND detInputExp.exp_tag = detResidImfile.exp_tag\n"
+        "   AND detInputExp.exp_id = detResidImfile.exp_id\n"
         "   AND detNormalizedImfile.class_id = detResidImfile.class_id\n"
         " WHERE\n"
@@ -4681,5 +4681,5 @@
         "  AND detResidImfile.det_id IS NULL\n"
         "  AND detResidImfile.iteration IS NULL\n"
-        "  AND detResidImfile.exp_tag IS NULL\n"
+        "  AND detResidImfile.exp_id IS NULL\n"
         "  AND detResidImfile.class_id IS NULL\n"
         " UNION\n"
@@ -4703,11 +4703,11 @@
         "    USING(det_id, iteration)\n"
         " JOIN rawExp\n"
-        "    ON detInputExp.exp_tag = rawExp.exp_tag\n"
+        "    ON detInputExp.exp_id = rawExp.exp_id\n"
         " JOIN rawImfile\n"
-        "    ON detInputExp.exp_tag = rawImfile.exp_tag\n"
+        "    ON detInputExp.exp_id = rawImfile.exp_id\n"
         " LEFT JOIN detResidImfile\n"
         "   ON detRun.det_id = detResidImfile.det_id\n"
         "   AND detRun.iteration = detResidImfile.iteration\n"
-        "   AND rawImfile.exp_tag = detResidImfile.exp_tag\n"
+        "   AND rawImfile.exp_id = detResidImfile.exp_id\n"
         "   AND rawImfile.class_id = detResidImfile.class_id\n"
         " WHERE\n"
@@ -4716,7 +4716,7 @@
         "   AND detResidImfile.det_id IS NULL\n"
         "   AND detResidImfile.iteration IS NULL\n"
-        "   AND detResidImfile.exp_tag IS NULL\n"
+        "   AND detResidImfile.exp_id IS NULL\n"
         "   AND detResidImfile.class_id IS NULL\n"
-        "   AND detInputExp.exp_tag = '%1$s'\n"
+        "   AND detInputExp.exp_id = '%1$s'\n"
         ") AS foo\n"
         "  %2$s"
@@ -4776,15 +4776,15 @@
     psFree(where);
 
-    // exp_tag is manadatory to cross check that this is a exp_tag for this
+    // exp_id is manadatory to cross check that this is a exp_id for this
     // detRun
-    psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
+    psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
         psFree(whereClause);
         psFree(query);
         return false;
     }
-    if (!exp_tag) {
-        psError(PS_ERR_UNKNOWN, true, "-exp_tag is required");
+    if (!exp_id) {
+        psError(PS_ERR_UNKNOWN, true, "-exp_id is required");
         psFree(whereClause);
         psFree(query);
@@ -4792,5 +4792,5 @@
     }
 
-    if (!p_psDBRunQuery(config->dbh, query, exp_tag, whereClause)) {
+    if (!p_psDBRunQuery(config->dbh, query, exp_id, whereClause)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         psFree(whereClause);
@@ -4862,11 +4862,11 @@
 
     bool status = false;
-    psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
-        return false;
-    }
-    if (!exp_tag) {
-        psError(PS_ERR_UNKNOWN, true, "-exp_tag is required");
+    psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
+        return false;
+    }
+    if (!exp_id) {
+        psError(PS_ERR_UNKNOWN, true, "-exp_id is required");
         return false;
     }
@@ -4979,5 +4979,5 @@
             normalizedImfile->det_id,
             normalizedImfile->iteration,
-            exp_tag,
+            (psS64)atoll(exp_id),
             normalizedImfile->class_id,
             uri,
@@ -5020,5 +5020,5 @@
     // select detResidImfile.*
     // by:
-    // where det_id, iteration, exp_tag is not in detResidExp;
+    // where det_id, iteration, exp_id is not in detResidExp;
 
     psString query = psStringCopy(
@@ -5032,5 +5032,5 @@
         "   USING(det_id, iteration)"
         " JOIN rawExp"
-        "   USING(exp_tag)"
+        "   USING(exp_id)"
         " WHERE"
     );
@@ -5128,12 +5128,12 @@
     // select detRun.iteration
     // select detRun.det_type
-    // select detInputExp.exp_tag
+    // select detInputExp.exp_id
     // select detInputExp.include
     // by:
     // find the current iteration bassed on det_id
-    // find all exp_tags in the current det_id/iteration from detInputExp
+    // find all exp_ids in the current det_id/iteration from detInputExp
     // compare to detInputExp.imfiles to derResidImfile by class_id
     // and:
-    // detResidImfile.{det_id, iteration, exp_tag} is not in detResidExp
+    // detResidImfile.{det_id, iteration, exp_id} is not in detResidExp
 
     psString query = psStringCopy(
@@ -5143,5 +5143,5 @@
         "   det_type,\n"
         "   mode,\n"
-        "   exp_tag,\n"
+        "   exp_id,\n"
         "   include,\n"
         "   camera,\n"
@@ -5154,5 +5154,5 @@
         "       detRun.mode,\n"
         "       detRun.workdir,\n"
-        "       detInputExp.exp_tag,\n"
+        "       detInputExp.exp_id,\n"
         "       detInputExp.include,\n"
         "       rawExp.imfiles,\n"
@@ -5163,13 +5163,13 @@
         "       USING(det_id, iteration)\n"
         "   JOIN rawExp\n"
-        "       ON detInputExp.exp_tag = rawExp.exp_tag\n"
+        "       ON detInputExp.exp_id = rawExp.exp_id\n"
         "   JOIN detResidImfile\n"
         "       ON detRun.det_id = detResidImfile.det_id\n"
         "       AND detRun.iteration = detResidImfile.iteration\n"
-        "       AND detInputExp.exp_tag = detResidImfile.exp_tag\n"
+        "       AND detInputExp.exp_id = detResidImfile.exp_id\n"
         "   LEFT JOIN detResidExp\n"
         "       ON detResidImfile.det_id = detResidExp.det_id\n"
         "       AND detResidImfile.iteration = detResidExp.iteration\n"
-        "       AND detResidImfile.exp_tag = detResidExp.exp_tag\n"
+        "       AND detResidImfile.exp_id = detResidExp.exp_id\n"
         "   WHERE\n"
         "       detRun.state = 'run'\n"
@@ -5177,7 +5177,7 @@
         "       AND detResidExp.det_id IS NULL\n"
         "       AND detResidExp.iteration IS NULL\n"
-        "       AND detResidExp.exp_tag IS NULL\n"
+        "       AND detResidExp.exp_id IS NULL\n"
         "   GROUP BY\n"
-        "       detInputExp.exp_tag,\n"
+        "       detInputExp.exp_id,\n"
         "       detRun.iteration,\n"
         "       detRun.det_id\n"
@@ -5258,12 +5258,12 @@
     // select detRun.iteration
     // select detRun.det_type
-    // select detInputExp.exp_tag
+    // select detInputExp.exp_id
     // select detInputExp.include
     // by:
     // find the current iteration bassed on det_id
-    // find all exp_tags in the current det_id/iteration from detInputExp
+    // find all exp_ids in the current det_id/iteration from detInputExp
     // compare to detInputExp.imfiles to derResidImfile by class_id
     // and:
-    // detResidImfile.{det_id, iteration, exp_tag} is not in detResidExp
+    // detResidImfile.{det_id, iteration, exp_id} is not in detResidExp
 
     psString query = psStringCopy(
@@ -5271,5 +5271,5 @@
         "   det_id,"
         "   iteration,"
-        "   exp_tag,"
+        "   exp_id,"
         "   include"
         " FROM"
@@ -5278,5 +5278,5 @@
         "       detRun.iteration,"
         "       detRun.det_type,"
-        "       detInputExp.exp_tag,"
+        "       detInputExp.exp_id,"
         "       detInputExp.include,"
         "       rawExp.imfiles"
@@ -5285,20 +5285,20 @@
         "       USING(det_id, iteration)"
         "   JOIN rawExp"
-        "       ON detInputExp.exp_tag = rawExp.exp_tag"
+        "       ON detInputExp.exp_id = rawExp.exp_id"
         "   JOIN detResidImfile"
         "       ON detRun.det_id = detResidImfile.det_id"
         "       AND detRun.iteration = detResidImfile.iteration"
-        "       AND detInputExp.exp_tag = detResidImfile.exp_tag"
+        "       AND detInputExp.exp_id = detResidImfile.exp_id"
         "   LEFT JOIN detResidExp"
         "       ON detResidImfile.det_id = detResidExp.det_id"
         "       AND detResidImfile.iteration = detResidExp.iteration"
-        "       AND detResidImfile.exp_tag = detResidExp.exp_tag"
+        "       AND detResidImfile.exp_id = detResidExp.exp_id"
         "   WHERE"
         "       detRun.state = 'run'"
         "       AND detResidExp.det_id IS NULL"
         "       AND detResidExp.iteration IS NULL"
-        "       AND detResidExp.exp_tag IS NULL"
+        "       AND detResidExp.exp_id IS NULL"
         "   GROUP BY"
-        "       detInputExp.exp_tag,"
+        "       detInputExp.exp_id,"
         "       detRun.iteration,"
         "       detRun.det_id"
@@ -5309,5 +5309,5 @@
 
     {
-        // build a query to search by det_id, iteration, exp_tag
+        // build a query to search by det_id, iteration, exp_id
         psMetadata *where = psMetadataAlloc();
         bool status = false;
@@ -5342,14 +5342,14 @@
             return false;
         }
-        psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
-        if (!status) {
-            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
+        psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
+        if (!status) {
+            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
             psFree(where);
             psFree(query);
             return false;
         }
-        if (exp_tag) {
-            if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag", 0, "==", exp_tag)) {
-                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
+        if (exp_id) {
+            if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", exp_id)) {
+                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
                 psFree(where);
                 psFree(query);
@@ -5448,11 +5448,11 @@
         return false;
     }
-    psString exp_tag = psMetadataLookupStr(&status, row, "exp_tag");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for exp_tag");
-        return false;
-    }
-    if (!exp_tag) {
-        psError(PS_ERR_UNKNOWN, true, "exp_tag is required");
+    psString exp_id = psMetadataLookupStr(&status, row, "exp_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for exp_id");
+        return false;
+    }
+    if (!exp_id) {
+        psError(PS_ERR_UNKNOWN, true, "exp_id is required");
         return false;
     }
@@ -5565,5 +5565,5 @@
             det_id,
             iteration,
-            exp_tag,
+            (psS64)atoll(exp_id),
             recipe,
             bg,
@@ -5611,5 +5611,5 @@
         "   USING(det_id, iteration)"
         " JOIN detResidExp"
-        "   USING(det_id, iteration, exp_tag)"
+        "   USING(det_id, iteration, exp_id)"
         " WHERE"
         "   detRun.state = 'run'"
@@ -5697,7 +5697,7 @@
     // by:
     // find the current iteration bassed on det_id
-    // find all exp_tags in the current det_id/iteration from detInputExp
-    // find all exp_tags in the current det_id/iteration from detResidExp
-    // compare the counts of exp_tags
+    // find all exp_ids in the current det_id/iteration from detInputExp
+    // find all exp_ids in the current det_id/iteration from detResidExp
+    // compare the counts of exp_ids
 
     psString query = psStringCopy(
@@ -5716,5 +5716,5 @@
         "       detRun.mode,\n"
         "       detRun.workdir,\n"
-        "       detInputExp.exp_tag,\n"
+        "       detInputExp.exp_id,\n"
         "       rawExp.camera\n"
         "   FROM detRun\n"
@@ -5722,9 +5722,9 @@
         "       USING(det_id, iteration)\n"
         "   JOIN rawExp\n"
-        "       ON detInputExp.exp_tag = rawExp.exp_tag\n"
+        "       ON detInputExp.exp_id = rawExp.exp_id\n"
         "   LEFT JOIN detResidExp\n"
         "       ON detRun.det_id = detResidExp.det_id\n"
         "       AND detRun.iteration = detResidExp.iteration\n"
-        "       AND detInputExp.exp_tag = detResidExp.exp_tag\n"
+        "       AND detInputExp.exp_id = detResidExp.exp_id\n"
         "   WHERE\n"
         "       detRun.state = 'run'\n"
@@ -5733,5 +5733,5 @@
         "       detRun.iteration\n"
         "   HAVING\n"
-        "       COUNT(detResidExp.exp_tag) = COUNT(detInputExp.exp_tag)\n"
+        "       COUNT(detResidExp.exp_id) = COUNT(detInputExp.exp_id)\n"
         " ) AS residdetrun\n"
         );
@@ -5797,5 +5797,5 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    // build a query to search by det_id, iteration, exp_tag
+    // build a query to search by det_id, iteration, exp_id
     psMetadata *where = psMetadataAlloc();
     bool status = false;
@@ -5825,13 +5825,13 @@
         return false;
     }
-    psString exp_tag = psMetadataLookupStr(&status, config->args, "-exp_tag");
-    if (!status) {
-        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_tag");
+    psString exp_id = psMetadataLookupStr(&status, config->args, "-exp_id");
+    if (!status) {
+        psError(PS_ERR_UNKNOWN, false, "failed to lookup value for -exp_id");
         psFree(where);
         return false;
     }
-    if (exp_tag) {
-        if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag", 0, "==", exp_tag)) {
-            psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
+    if (exp_id) {
+        if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id", 0, "==", exp_id)) {
+            psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
             psFree(where);
             return false;
@@ -5840,5 +5840,5 @@
 
     // find the values we're going to set
-    // copy everything but det_id, iteration, & exp_tag from the args and
+    // copy everything but det_id, iteration, & exp_id from the args and
     // remove the '-' prefix
     psMetadata *set = psMetadataAlloc();
@@ -5957,7 +5957,7 @@
     // by:
     // find the current iteration bassed on det_id
-    // find all exp_tags in the current det_id/iteration from detInputExp
-    // find all exp_tags in the current det_id/iteration from detResidExp
-    // compare the counts of exp_tags
+    // find all exp_ids in the current det_id/iteration from detInputExp
+    // find all exp_ids in the current det_id/iteration from detResidExp
+    // compare the counts of exp_ids
 
     psString query = pxDataGet("dettool_find_completed_runs.sql");
@@ -5968,5 +5968,5 @@
 
     {
-        // build a query to search by det_id, iteration, exp_tag
+        // build a query to search by det_id, iteration, exp_id
         psMetadata *where = psMetadataAlloc();
         bool status = false;
@@ -6271,11 +6271,11 @@
     // select detRun.det_id
     // select detRun.iteration
-    // select detInputExp.exp_tag
+    // select detInputExp.exp_id
     // select detResidExp.accept
     // by:
     // find the current iteration bassed on det_id
-    // find all exp_tags in the current det_id/iteration from detInputExp
-    // find all exp_tags in the current det_id/iteration from detResidExp
-    // compare the counts of exp_tags
+    // find all exp_ids in the current det_id/iteration from detInputExp
+    // find all exp_ids in the current det_id/iteration from detResidExp
+    // compare the counts of exp_ids
 
     psString query = psStringCopy(
@@ -6283,5 +6283,5 @@
         "   detRun.det_id AS det_id,"
         "   detRun.iteration,"
-        "   detInputExp.exp_tag,"
+        "   detInputExp.exp_id,"
         "   detResidExp.accept"
         " FROM detRun"
@@ -6292,5 +6292,5 @@
         "   ON detRun.det_id = detResidExp.det_id"
         "   AND detRun.iteration = detResidExp.iteration"
-        "   AND detInputExp.exp_tag = detResidExp.exp_tag"
+        "   AND detInputExp.exp_id = detResidExp.exp_id"
         " WHERE"
         "   detRun.state = 'run'"
@@ -6310,7 +6310,7 @@
         "   detRun.det_id,"
         "   detRun.iteration,"
-        "   detInputExp.exp_tag"
+        "   detInputExp.exp_id"
         " HAVING"
-        "   COUNT(detResidExp.exp_tag) = COUNT(detInputExp.exp_tag)"
+        "   COUNT(detResidExp.exp_id) = COUNT(detInputExp.exp_id)"
         );
 
@@ -6357,5 +6357,5 @@
     for (long i = 0; i < psArrayLength(output); i++) {
         psMetadata *row = output->data[i];
-        psString exp_tag = psMetadataLookupStr(&status, row, "exp_tag");
+        psString exp_id = psMetadataLookupStr(&status, row, "exp_id");
         if (!status) {
             // rollback
@@ -6363,5 +6363,5 @@
                 psError(PS_ERR_UNKNOWN, false, "database error");
             }
-            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for exp_tag");
+            psError(PS_ERR_UNKNOWN, false, "failed to lookup value for exp_id");
             psFree(output);
             return false;
@@ -6383,5 +6383,5 @@
                     (psS32)atol(det_id),
                     newIteration,
-                    exp_tag,
+                    (psS64)atoll(exp_id),
                     accept
                 )
@@ -6424,15 +6424,15 @@
     }
 
-    // we have to support multipe exp_tags
-    psMetadataItem *item = psMetadataLookup(config->args, "-exp_tag");
+    // we have to support multipe exp_ids
+    psMetadataItem *item = psMetadataLookup(config->args, "-exp_id");
     if (!item) {
         // this shouldn't actually happen when using psArgs
-        psError(PS_ERR_UNKNOWN, true, "-exp_tag is required");
-        return false;
-    }
-
-    psList *exp_tag_list = item->data.list;
+        psError(PS_ERR_UNKNOWN, true, "-exp_id is required");
+        return false;
+    }
+
+    psList *exp_id_list = item->data.list;
     psMetadata *where = psMetadataAlloc();
-    // make sure that -exp_tag was parsed correctly
+    // make sure that -exp_id was parsed correctly
     // XXX this can be removed someday
     if (item->type == PS_DATA_METADATA_MULTI) {
@@ -6440,17 +6440,17 @@
         psMetadataItem *mItem = NULL;
         while ((mItem = psListGetAndIncrement(iter))) {
-            psString exp_tag = mItem->data.V;
-            // if exp_tag is NULL then it means that -exp_tag has not been
+            psString exp_id = mItem->data.V;
+            // if exp_id is NULL then it means that -exp_id has not been
             // specified
-            if (!exp_tag) {
+            if (!exp_id) {
                 psError(PS_ERR_UNKNOWN, true,
-                        "at least one -exp_tag is required");
+                        "at least one -exp_id is required");
                 psFree(where);
                 return false;
             }
 
-            if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_tag",
-                        PS_META_DUPLICATE_OK, "==", exp_tag)) {
-                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_tag");
+            if (!psMetadataAddStr(where, PS_LIST_TAIL, "exp_id",
+                        PS_META_DUPLICATE_OK, "==", exp_id)) {
+                psError(PS_ERR_UNKNOWN, false, "failed to add item exp_id");
                 psFree(iter);
                 psFree(where);
@@ -6460,8 +6460,8 @@
         psFree(iter);
     } else {
-        psAbort(                "-exp_tag was not parsed correctly (this should not happen");
-    }
-
-    // check that the specified exp_tags actually exist in the iteration zero
+        psAbort(                "-exp_id was not parsed correctly (this should not happen");
+    }
+
+    // check that the specified exp_ids actually exist in the iteration zero
     // detInputExp set
 
@@ -6487,12 +6487,15 @@
     }
 
-    // build a hash for the valid exp_tags
-    psHash *valid_exp_tags = psHashAlloc(psArrayLength(detrendExps));
+    // build a hash for the valid exp_ids
+    psHash *valid_exp_ids = psHashAlloc(psArrayLength(detrendExps));
+// XXX: FIXME!
+#if 0
     for (long i = 0; i < psArrayLength(detrendExps); i++) {
-        psHashAdd(valid_exp_tags,
-            ((detInputExpRow *)detrendExps->data[i])->exp_tag,
+        psHashAdd(valid_exp_ids,
+            ((detInputExpRow *)detrendExps->data[i])->exp_id,
             detrendExps->data[i]
         );
     }
+#endif
     psFree(detrendExps);
 
@@ -6501,5 +6504,5 @@
     if (!psDBTransaction(config->dbh)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
-        psFree(valid_exp_tags);
+        psFree(valid_exp_ids);
         return false;
     }
@@ -6512,15 +6515,15 @@
             psError(PS_ERR_UNKNOWN, false, "database error");
         }
-        psFree(valid_exp_tags);
-        return false;
-    }
-
-    // check exp_tags and build up an array of new detInputExp rows at the same
+        psFree(valid_exp_ids);
+        return false;
+    }
+
+    // check exp_ids and build up an array of new detInputExp rows at the same
     // time
-    psListIterator *iter = psListIteratorAlloc(exp_tag_list, 0, false);
+    psListIterator *iter = psListIteratorAlloc(exp_id_list, 0, false);
     psMetadataItem *mItem = NULL;
-    psArray *newInputExps = psArrayAllocEmpty(psListLength(exp_tag_list));
+    psArray *newInputExps = psArrayAllocEmpty(psListLength(exp_id_list));
     while ((mItem = psListGetAndIncrement(iter))) {
-        detInputExpRow *inputExp = psHashLookup(valid_exp_tags,
+        detInputExpRow *inputExp = psHashLookup(valid_exp_ids,
                 (char *)mItem->data.V);
         if (!inputExp) {
@@ -6529,9 +6532,9 @@
                 psError(PS_ERR_UNKNOWN, false, "database error");
             }
-            // invalid exp_tag
-            psError(PS_ERR_UNKNOWN, false, "exp_tag %s is invalid for det_id %s",
+            // invalid exp_id
+            psError(PS_ERR_UNKNOWN, false, "exp_id %s is invalid for det_id %s",
                     (char *)mItem->data.V, det_id);
             psFree(iter);
-            psFree(valid_exp_tags);
+            psFree(valid_exp_ids);
             return false;
         }
@@ -6539,5 +6542,5 @@
             (psS32)atol(det_id),
             newIteration,
-            inputExp->exp_tag,
+            inputExp->exp_id,
             true   // use
         );
@@ -6546,5 +6549,5 @@
     }
     psFree(iter);
-    psFree(valid_exp_tags);
+    psFree(valid_exp_ids);
 
     for (long i = 0; i < psArrayLength(newInputExps); i++) {
