Index: trunk/ippTools/src/camtool.c
===================================================================
--- trunk/ippTools/src/camtool.c	(revision 23661)
+++ trunk/ippTools/src/camtool.c	(revision 23688)
@@ -468,5 +468,6 @@
 
     PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", false, false);
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
+    PXOPT_LOOKUP_S16(quality, config->args, "-quality", false, false);
 
     // generate restrictions
@@ -533,15 +534,15 @@
         zpt_lq,
         zpt_uq,
-	fwhm_major,
-	fwhm_major_lq,
-	fwhm_major_uq,
-	fwhm_minor,
-	fwhm_minor_lq,
-	fwhm_minor_uq,
-
-	iq_fwhm_major,
-	iq_fwhm_major_err,
-	iq_fwhm_minor,
-	iq_fwhm_minor_err,
+        fwhm_major,
+        fwhm_major_lq,
+        fwhm_major_uq,
+        fwhm_minor,
+        fwhm_minor_lq,
+        fwhm_minor_uq,
+
+        iq_fwhm_major,
+        iq_fwhm_major_err,
+        iq_fwhm_minor,
+        iq_fwhm_minor_err,
 
         iq_m2,
@@ -576,5 +577,6 @@
         n_astrom,
         path_base,
-        code
+        fault,
+        quality
         );
 
@@ -599,7 +601,7 @@
 
     // NULL for end_stage means go as far as possible
-    // EAM : skip here if code != 0
+    // EAM : skip here if fault != 0
     // Also, we can run fake even if tess_id is not defined
-    if (code || (pendingRow->end_stage && psStrcasestr(pendingRow->end_stage, "cam"))) {
+    if (fault || (pendingRow->end_stage && psStrcasestr(pendingRow->end_stage, "cam"))) {
         psFree(row);
         psFree(pendingRow);
@@ -745,5 +747,5 @@
     PXOPT_COPY_STR(config->args, where, "-label",     "camRun.label",          "==");
     PXOPT_COPY_STR(config->args, where, "-reduction", "camRun.reduction",      "==");
-    PXOPT_COPY_S16(config->args, where, "-code",      "camProcessedExp.fault", "==");
+    PXOPT_COPY_S16(config->args, where, "-fault", "camProcessedExp.fault", "==");
 
     if (!psListLength(where->list) && !psMetadataLookupBool(NULL, config->args, "-all")) {
@@ -833,5 +835,5 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    PXOPT_LOOKUP_S16(code, config->args, "-code", true, false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false);
 
     psMetadata *where = psMetadataAlloc();
@@ -841,5 +843,5 @@
     PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "==");
 
-    if (!pxSetFaultCode(config->dbh, "camProcessedExp", where, code)) {
+    if (!pxSetFaultCode(config->dbh, "camProcessedExp", where, fault)) {
         psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
         psFree (where);
@@ -1114,5 +1116,5 @@
     char sqlFilename[80];
   } ExportTable;
-  
+
   int numExportTables = 2;
 
@@ -1194,5 +1196,5 @@
 
   PS_ASSERT_PTR_NON_NULL(config, NULL);
-  
+
   PXOPT_LOOKUP_STR(infile, config->args, "-infile", true,  false);
 
@@ -1205,5 +1207,5 @@
   psAssert (item, "entry not in input?");
   psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");
-  
+
   psMetadataItem *entry = psListGet (item->data.list, 0);
   assert (entry);
@@ -1214,5 +1216,5 @@
   // fprintf (stdout, "---- cam run ----\n");
   // psMetadataPrint (stderr, entry->data.md, 1);
-  
+
   item = psMetadataLookup (input, "camProcessedImfile");
   psAssert (item, "entry not in input?");
Index: trunk/ippTools/src/camtoolConfig.c
===================================================================
--- trunk/ippTools/src/camtoolConfig.c	(revision 23661)
+++ trunk/ippTools/src/camtoolConfig.c	(revision 23688)
@@ -164,5 +164,6 @@
 
     psMetadataAddStr(addprocessedexpArgs, PS_LIST_TAIL, "-path_base", 0,            "define base output location", NULL);
-    psMetadataAddS16(addprocessedexpArgs, PS_LIST_TAIL, "-code",  0,            "set fault code", 0);
+    psMetadataAddS16(addprocessedexpArgs, PS_LIST_TAIL, "-fault",  0,            "set fault code", 0);
+    psMetadataAddS16(addprocessedexpArgs, PS_LIST_TAIL, "-quality",  0,            "set quality", 0);
     psMetadataAddBool(addprocessedexpArgs, PS_LIST_TAIL, "-faulted",  0,            "only return imfiles with a fault status set", false);
 
@@ -191,4 +192,5 @@
 
     psMetadataAddBool(revertprocessedexpArgs, PS_LIST_TAIL, "-all",  0,            "allow everything to be queued without search terms", false);
+    psMetadataAddS16(revertprocessedexpArgs, PS_LIST_TAIL, "-fault",  0,            "search by fault code", 0);
 
     // -updateprocessedexp
@@ -199,5 +201,5 @@
     psMetadataAddStr(updateprocessedexpArgs, PS_LIST_TAIL, "-class",  0,            "search by class", NULL);
     psMetadataAddStr(updateprocessedexpArgs, PS_LIST_TAIL, "-class_id",  0,            "search by class ID", NULL);
-    psMetadataAddS16(updateprocessedexpArgs, PS_LIST_TAIL, "-code",  0,            "set fault code (required)", INT16_MAX);
+    psMetadataAddS16(updateprocessedexpArgs, PS_LIST_TAIL, "-fault",  0,            "set fault code (required)", INT16_MAX);
 
     // -block
Index: trunk/ippTools/src/chiptool.c
===================================================================
--- trunk/ippTools/src/chiptool.c	(revision 23661)
+++ trunk/ippTools/src/chiptool.c	(revision 23688)
@@ -409,14 +409,15 @@
     PXOPT_LOOKUP_F32(dtime_script, config->args,   "-dtime_script", false, false);
     PXOPT_LOOKUP_STR(hostname, config->args,       "-hostname", false, false);
-    PXOPT_LOOKUP_F32(n_stars, config->args,    	   "-n_stars", false, false);
-    PXOPT_LOOKUP_F32(n_psfstars, config->args,	   "-n_psfstars", false, false);
-    PXOPT_LOOKUP_F32(n_iqstars, config->args, 	   "-n_iqstars", false, false);
-    PXOPT_LOOKUP_F32(n_extended, config->args, 	   "-n_extended", false, false);
-    PXOPT_LOOKUP_F32(n_cr, config->args,       	   "-n_cr", false, false);
-    PXOPT_LOOKUP_STR(path_base, config->args,  	   "-path_base", false, false);
-    PXOPT_LOOKUP_BOOL(magicked, config->args,  	   "-magicked", false);
+    PXOPT_LOOKUP_F32(n_stars, config->args,        "-n_stars", false, false);
+    PXOPT_LOOKUP_F32(n_psfstars, config->args,     "-n_psfstars", false, false);
+    PXOPT_LOOKUP_F32(n_iqstars, config->args,      "-n_iqstars", false, false);
+    PXOPT_LOOKUP_F32(n_extended, config->args,     "-n_extended", false, false);
+    PXOPT_LOOKUP_F32(n_cr, config->args,           "-n_cr", false, false);
+    PXOPT_LOOKUP_STR(path_base, config->args,      "-path_base", false, false);
+    PXOPT_LOOKUP_BOOL(magicked, config->args,      "-magicked", false);
 
     // default values
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
+    PXOPT_LOOKUP_S16(quality, config->args, "-quality", false, false);
 
     if (!psDBTransaction(config->dbh)) {
@@ -449,33 +450,33 @@
                                    fwhm_minor_uq,
 
-				   iq_fwhm_major,
-				   iq_fwhm_major_err,
-				   iq_fwhm_minor,
-				   iq_fwhm_minor_err,
-
-				   iq_m2,
-				   iq_m2_err,
-				   iq_m2_lq,
-				   iq_m2_uq,
-
-				   iq_m2c,
-				   iq_m2c_err,
-				   iq_m2c_lq,
-				   iq_m2c_uq,
-
-				   iq_m2s,
-				   iq_m2s_err,
-				   iq_m2s_lq,
-				   iq_m2s_uq,
-
-				   iq_m3,
-				   iq_m3_err,
-				   iq_m3_lq,
-				   iq_m3_uq,
-
-				   iq_m4,
-				   iq_m4_err,
-				   iq_m4_lq,
-				   iq_m4_uq,
+                                   iq_fwhm_major,
+                                   iq_fwhm_major_err,
+                                   iq_fwhm_minor,
+                                   iq_fwhm_minor_err,
+
+                                   iq_m2,
+                                   iq_m2_err,
+                                   iq_m2_lq,
+                                   iq_m2_uq,
+
+                                   iq_m2c,
+                                   iq_m2c_err,
+                                   iq_m2c_lq,
+                                   iq_m2c_uq,
+
+                                   iq_m2s,
+                                   iq_m2s_err,
+                                   iq_m2s_lq,
+                                   iq_m2s_uq,
+
+                                   iq_m3,
+                                   iq_m3_err,
+                                   iq_m3_lq,
+                                   iq_m3_uq,
+
+                                   iq_m4,
+                                   iq_m4_err,
+                                   iq_m4_lq,
+                                   iq_m4_uq,
 
                                    dtime_detrend,
@@ -490,5 +491,6 @@
                                    n_cr,
                                    path_base,
-                                   code,
+                                   fault,
+                                   quality,
                                    magicked
             )) {
@@ -618,5 +620,5 @@
     PXOPT_COPY_STR(config->args, where, "-label", "chipRun.label", "LIKE");
     PXOPT_COPY_STR(config->args, where, "-reduction", "chipRun.reduction", "==");
-    PXOPT_COPY_S16(config->args, where, "-code", "chipProcessedImfile.fault", "==");
+    PXOPT_COPY_S16(config->args, where, "-fault", "chipProcessedImfile.fault", "==");
 
     if (!psListLength(where->list)
@@ -659,7 +661,7 @@
     PXOPT_COPY_S64(config->args, where, "-chip_id", "chip_id", "==");
     PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "==");
-    PXOPT_LOOKUP_S16(code, config->args, "-code", true, false);
-
-    if (!pxSetFaultCode(config->dbh, "chipProcessedImfile", where, code)) {
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false);
+
+    if (!pxSetFaultCode(config->dbh, "chipProcessedImfile", where, fault)) {
         psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
         return false;
@@ -1280,5 +1282,5 @@
     char sqlFilename[80];
   } ExportTable;
-  
+
   int numExportTables = 3;
 
@@ -1360,11 +1362,11 @@
 {
   unsigned int nFail;
-  
+
   int numImportTables = 2;
- 
+
   char tables[2] [80] = {"chipImfile", "chipProcessedImfile"};
 
   PS_ASSERT_PTR_NON_NULL(config, NULL);
-  
+
   PXOPT_LOOKUP_STR(infile, config->args, "-infile", true,  false);
 
@@ -1386,10 +1388,10 @@
   // fprintf (stdout, "---- chip run ----\n");
   // psMetadataPrint (stderr, entry->data.md, 1);
-  
+
   for (int i = 0; i < numImportTables; i++) {
     psMetadataItem *item = psMetadataLookup (input, tables[i]);
     psAssert (item, "entry not in input?");
     psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");
-  
+
     switch (i) {
       case 0:
@@ -1405,5 +1407,5 @@
         }
         break;
-        
+
       case 1:
         for (int i = 0; i < item->data.list->n; i++) {
Index: trunk/ippTools/src/chiptoolConfig.c
===================================================================
--- trunk/ippTools/src/chiptoolConfig.c	(revision 23661)
+++ trunk/ippTools/src/chiptoolConfig.c	(revision 23688)
@@ -146,5 +146,6 @@
 
     psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-path_base",  0,            "define base output location", NULL);
-    psMetadataAddS16(addprocessedimfileArgs, PS_LIST_TAIL, "-code",  0,            "set fault code", 0);
+    psMetadataAddS16(addprocessedimfileArgs, PS_LIST_TAIL, "-fault",  0,            "set fault code", 0);
+    psMetadataAddS16(addprocessedimfileArgs, PS_LIST_TAIL, "-quality",  0,            "set quality", 0);
     psMetadataAddBool(addprocessedimfileArgs, PS_LIST_TAIL, "-magicked",  0,        "define magicked status", false);
 
@@ -171,5 +172,5 @@
     pxchipSetSearchArgs(revertprocessedimfileArgs);
     psMetadataAddBool(revertprocessedimfileArgs, PS_LIST_TAIL, "-all",  0,            "allow everything to be queued without search terms", false);
-    psMetadataAddS16(revertprocessedimfileArgs, PS_LIST_TAIL, "-code",  0,            "search by fault code", 0);
+    psMetadataAddS16(revertprocessedimfileArgs, PS_LIST_TAIL, "-fault",  0,            "search by fault code", 0);
 
     // -updateprocessedimfile
@@ -177,5 +178,5 @@
     psMetadataAddS64(updateprocessedimfileArgs, PS_LIST_TAIL, "-chip_id",  0,            "search by chip ID", 0);
     psMetadataAddStr(updateprocessedimfileArgs,  PS_LIST_TAIL, "-class_id",           0, "search by class ID", NULL);
-    psMetadataAddS16(updateprocessedimfileArgs, PS_LIST_TAIL, "-code",  0,            "set fault code (required)", 0);
+    psMetadataAddS16(updateprocessedimfileArgs, PS_LIST_TAIL, "-fault",  0,            "set fault code (required)", 0);
 
     // -advanceexp
Index: trunk/ippTools/src/dettoolConfig.c
===================================================================
--- trunk/ippTools/src/dettoolConfig.c	(revision 23661)
+++ trunk/ippTools/src/dettoolConfig.c	(revision 23688)
@@ -254,5 +254,5 @@
     psMetadataAddS64(addprocessedimfileArgs, PS_LIST_TAIL, "-exp_id",  0,            "define exp ID (required)", 0);
     psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-class_id",  0,            "define class ID (required)", NULL);
-    psMetadataAddS16(addprocessedimfileArgs, PS_LIST_TAIL, "-code",  0,            "set fault code", 0);
+    psMetadataAddS16(addprocessedimfileArgs, PS_LIST_TAIL, "-fault",  0,            "set fault code", 0);
     psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-uri",  0,            "define URI", NULL);
     psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-recip",  0,            "define recipe", NULL);
@@ -287,5 +287,5 @@
     psMetadataAddS64(revertprocessedimfileArgs, PS_LIST_TAIL, "-exp_id",  0,            "search by exposure ID", 0);
     psMetadataAddStr(revertprocessedimfileArgs, PS_LIST_TAIL, "-class_id",  0,            "search by class ID", NULL);
-    psMetadataAddS16(revertprocessedimfileArgs, PS_LIST_TAIL, "-code",  0,            "search by fault code", 0);
+    psMetadataAddS16(revertprocessedimfileArgs, PS_LIST_TAIL, "-fault",  0,            "search by fault code", 0);
 
     // -updateprocessedimfile
@@ -334,5 +334,5 @@
     psMetadataAddF64(addprocessedexpArgs, PS_LIST_TAIL, "-user_5",  0,            "define user statistic (5)", NAN);
     psMetadataAddStr(addprocessedexpArgs, PS_LIST_TAIL, "-path_base",  0,            "define base output location", NULL);
-    psMetadataAddS16(addprocessedexpArgs, PS_LIST_TAIL, "-code",  0,            "set fault code", 0);
+    psMetadataAddS16(addprocessedexpArgs, PS_LIST_TAIL, "-fault",  0,            "set fault code", 0);
 
     // -proccessedexp
@@ -348,5 +348,5 @@
     psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-det_id",  0,            "search by detrend ID (required)", 0);
     psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-exp_id",  0,            "search by exposure ID", 0);
-    psMetadataAddS16(revertprocessedexpArgs, PS_LIST_TAIL, "-code",  0,            "search by fault code", 0);
+    psMetadataAddS16(revertprocessedexpArgs, PS_LIST_TAIL, "-fault",  0,            "search by fault code", 0);
 
     // -updateprocessedexp
@@ -380,5 +380,5 @@
     psMetadataAddS32(addstackedArgs, PS_LIST_TAIL, "-iteration",  0,            "define iteration number (required)", 0);
     psMetadataAddStr(addstackedArgs, PS_LIST_TAIL, "-class_id",  0,            "define class ID (required)", NULL);
-    psMetadataAddS16(addstackedArgs, PS_LIST_TAIL, "-code",  0,            "set fault code", 0);
+    psMetadataAddS16(addstackedArgs, PS_LIST_TAIL, "-fault",  0,            "set fault code", 0);
     psMetadataAddStr(addstackedArgs, PS_LIST_TAIL, "-uri",  0,            "define URI", NULL);
     psMetadataAddStr(addstackedArgs, PS_LIST_TAIL, "-recip",  0,            "define recipe", NULL);
@@ -407,5 +407,5 @@
     psMetadataAddS32(revertstackedArgs, PS_LIST_TAIL, "-iteration",  0,            "search by iteration number", 0);
     psMetadataAddStr(revertstackedArgs, PS_LIST_TAIL, "-class_id",  0,            "search by class ID", NULL);
-    psMetadataAddS16(revertstackedArgs, PS_LIST_TAIL, "-code",  0,            "search by fault code", 0);
+    psMetadataAddS16(revertstackedArgs, PS_LIST_TAIL, "-fault",  0,            "search by fault code", 0);
 
     // -updatestacked
@@ -443,5 +443,5 @@
     psMetadataAddStr(addnormstatArgs, PS_LIST_TAIL, "-class_id",  0,            "define class ID (required)", NULL);
     psMetadataAddF32(addnormstatArgs, PS_LIST_TAIL, "-norm",  0,            "define normal value (required)", NAN);
-    psMetadataAddS16(addnormstatArgs, PS_LIST_TAIL, "-code",  0,            "set fault code", 0);
+    psMetadataAddS16(addnormstatArgs, PS_LIST_TAIL, "-fault",  0,            "set fault code", 0);
 
     // -normalizedstat
@@ -459,5 +459,5 @@
     psMetadataAddS32(revertnormalizedstatArgs, PS_LIST_TAIL, "-iteration",  0,            "search by iteration number", 0);
     psMetadataAddStr(revertnormalizedstatArgs, PS_LIST_TAIL, "-class_id",  0,            "search by class ID", NULL);
-    psMetadataAddS16(revertnormalizedstatArgs, PS_LIST_TAIL, "-code",  0,            "search by fault code", 0);
+    psMetadataAddS16(revertnormalizedstatArgs, PS_LIST_TAIL, "-fault",  0,            "search by fault code", 0);
 
     // -updatenormalizedstat
@@ -494,5 +494,5 @@
     psMetadataAddS32(addnormalizedimfileArgs, PS_LIST_TAIL, "-iteration", 0,            "define iteration number", 0);
     psMetadataAddStr(addnormalizedimfileArgs, PS_LIST_TAIL, "-class_id", 0,            "define class ID (required)", NULL);
-    psMetadataAddS16(addnormalizedimfileArgs, PS_LIST_TAIL, "-code",  0,            "set fault code", 0);
+    psMetadataAddS16(addnormalizedimfileArgs, PS_LIST_TAIL, "-fault",  0,            "set fault code", 0);
     psMetadataAddStr(addnormalizedimfileArgs, PS_LIST_TAIL, "-uri", 0,            "define URI", NULL);
     psMetadataAddF64(addnormalizedimfileArgs, PS_LIST_TAIL, "-bg", 0,            "define exposure background", NAN);
@@ -521,5 +521,5 @@
     psMetadataAddS32(revertnormalizedimfileArgs, PS_LIST_TAIL, "-iteration", 0,            "search by iteration number", 0);
     psMetadataAddStr(revertnormalizedimfileArgs, PS_LIST_TAIL, "-class_id", 0,            "search by class ID", NULL);
-    psMetadataAddS16(revertnormalizedimfileArgs, PS_LIST_TAIL, "-code",  0,            "search by fault code", 0);
+    psMetadataAddS16(revertnormalizedimfileArgs, PS_LIST_TAIL, "-fault",  0,            "search by fault code", 0);
 
     // -updatenormalizedimfile
@@ -555,5 +555,5 @@
     psMetadataAddS64(addnormalizedexpArgs, PS_LIST_TAIL, "-det_id",  0,            "define detrend ID (required)", 0);
     psMetadataAddS32(addnormalizedexpArgs, PS_LIST_TAIL, "-iteration",  0,            "define iteration number", 0);
-    psMetadataAddS16(addnormalizedexpArgs, PS_LIST_TAIL, "-code",  0,            "set fault code", 0);
+    psMetadataAddS16(addnormalizedexpArgs, PS_LIST_TAIL, "-fault",  0,            "set fault code", 0);
     psMetadataAddStr(addnormalizedexpArgs, PS_LIST_TAIL, "-recip",  0,            "search for recipe", NULL);
     psMetadataAddF64(addnormalizedexpArgs, PS_LIST_TAIL, "-bg",  0,            "define exposure background", NAN);
@@ -580,5 +580,5 @@
     psMetadataAddS64(revertnormalizedexpArgs, PS_LIST_TAIL, "-det_id", 0,            "search by detrend ID (required)", 0);
     psMetadataAddS32(revertnormalizedexpArgs, PS_LIST_TAIL, "-iteration", 0,            "search by iteration number", 0);
-    psMetadataAddS16(revertnormalizedexpArgs, PS_LIST_TAIL, "-code",  0,            "search by fault code", 0);
+    psMetadataAddS16(revertnormalizedexpArgs, PS_LIST_TAIL, "-fault",  0,            "search by fault code", 0);
 
     // -updatenormalizedexp
@@ -616,5 +616,5 @@
     psMetadataAddS64(addresidimfileArgs, PS_LIST_TAIL, "-exp_id",  0,            "define detrend ID (required)", 0);
     psMetadataAddStr(addresidimfileArgs, PS_LIST_TAIL, "-class_id",  0,          "define class ID (required)", NULL);
-    psMetadataAddS16(addresidimfileArgs, PS_LIST_TAIL, "-code",  0,              "set fault code", 0);
+    psMetadataAddS16(addresidimfileArgs, PS_LIST_TAIL, "-fault",  0,              "set fault code", 0);
     psMetadataAddStr(addresidimfileArgs, PS_LIST_TAIL, "-uri",  0,               "define resid file URI", NULL);
     psMetadataAddStr(addresidimfileArgs, PS_LIST_TAIL, "-recip",  0,             "define recipe", NULL);
@@ -658,5 +658,5 @@
     psMetadataAddS64(revertresidimfileArgs, PS_LIST_TAIL, "-exp_id",  0,         "search by detrend ID", 0);
     psMetadataAddStr(revertresidimfileArgs, PS_LIST_TAIL, "-class_id",  0,       "search for class ID", NULL);
-    psMetadataAddS16(revertresidimfileArgs, PS_LIST_TAIL, "-code",  0,           "search by fault code", 0);
+    psMetadataAddS16(revertresidimfileArgs, PS_LIST_TAIL, "-fault",  0,           "search by fault code", 0);
 
     // -updateresidimfile
@@ -696,5 +696,5 @@
     psMetadataAddS32(addresidexpArgs, PS_LIST_TAIL, "-iteration",  0,            "define iteration number", 0);
     psMetadataAddS64(addresidexpArgs, PS_LIST_TAIL, "-exp_id",  0,            "define detrend ID (required)", 0);
-    psMetadataAddS16(addresidexpArgs, PS_LIST_TAIL, "-code",  0,            "set fault code", 0);
+    psMetadataAddS16(addresidexpArgs, PS_LIST_TAIL, "-fault",  0,            "set fault code", 0);
     psMetadataAddStr(addresidexpArgs, PS_LIST_TAIL, "-recip",  0,            "define recipe", NULL);
     psMetadataAddF64(addresidexpArgs, PS_LIST_TAIL, "-bg",  0,            "define exposure background", NAN);
@@ -734,5 +734,5 @@
     psMetadataAddS32(revertresidexpArgs, PS_LIST_TAIL, "-iteration", 0,            "search by iteration number", 0);
     psMetadataAddS64(revertresidexpArgs, PS_LIST_TAIL, "-exp_id",  0,            "search by detrend ID", 0);
-    psMetadataAddS16(revertresidexpArgs, PS_LIST_TAIL, "-code",  0,            "search by fault code", 0);
+    psMetadataAddS16(revertresidexpArgs, PS_LIST_TAIL, "-fault",  0,            "search by fault code", 0);
 
     // -updateresidexp
@@ -777,5 +777,5 @@
     psMetadataAddF64(adddetrunsummaryArgs, PS_LIST_TAIL, "-bg_stdev",  0,            "define exposure background stdev", NAN);
     psMetadataAddF64(adddetrunsummaryArgs, PS_LIST_TAIL, "-bg_mean_stdev",  0,            "define exposure background mean stdev", NAN);
-    psMetadataAddS16(adddetrunsummaryArgs, PS_LIST_TAIL, "-code",  0,            "set fault code", 0);
+    psMetadataAddS16(adddetrunsummaryArgs, PS_LIST_TAIL, "-fault",  0,            "set fault code", 0);
     psMetadataAddBool(adddetrunsummaryArgs, PS_LIST_TAIL, "-accept",  0,            "declare that this detrun iteration is accepted as a master", false);
     psMetadataAddBool(adddetrunsummaryArgs, PS_LIST_TAIL, "-again",  0,            "start a new iteration of this detrend run", false);
@@ -794,5 +794,5 @@
     psMetadataAddS64(revertdetrunsummaryArgs, PS_LIST_TAIL, "-det_id", 0,            "search by detrend ID (required)", 0);
     psMetadataAddS32(revertdetrunsummaryArgs, PS_LIST_TAIL, "-iteration", 0,            "search by iteration number", 0);
-    psMetadataAddS16(revertdetrunsummaryArgs, PS_LIST_TAIL, "-code",  0,            "search by fault code", 0);
+    psMetadataAddS16(revertdetrunsummaryArgs, PS_LIST_TAIL, "-fault",  0,            "search by fault code", 0);
 
     // -updatedetrunsummary
@@ -886,9 +886,9 @@
     PXOPT_ADD_MODE("-input",           "", DETTOOL_MODE_INPUT,         inputArgs);
 
-    PXOPT_ADD_MODE("-toprocessedimfile", "",  		  DETTOOL_MODE_TOPROCESSEDIMFILE, toprocessedimfileArgs);
-    PXOPT_ADD_MODE("-addprocessedimfile", "", 		  DETTOOL_MODE_ADDPROCESSEDIMFILE,  addprocessedimfileArgs);
-    PXOPT_ADD_MODE("-processedimfile", "",    		  DETTOOL_MODE_PROCESSEDIMFILE, processedimfileArgs);
-    PXOPT_ADD_MODE("-revertprocessedimfile", "", 	  DETTOOL_MODE_REVERTPROCESSEDIMFILE, revertprocessedimfileArgs);
-    PXOPT_ADD_MODE("-updateprocessedimfile", "", 	  DETTOOL_MODE_UPDATEPROCESSEDIMFILE, updateprocessedimfileArgs);
+    PXOPT_ADD_MODE("-toprocessedimfile", "",              DETTOOL_MODE_TOPROCESSEDIMFILE, toprocessedimfileArgs);
+    PXOPT_ADD_MODE("-addprocessedimfile", "",             DETTOOL_MODE_ADDPROCESSEDIMFILE,  addprocessedimfileArgs);
+    PXOPT_ADD_MODE("-processedimfile", "",                DETTOOL_MODE_PROCESSEDIMFILE, processedimfileArgs);
+    PXOPT_ADD_MODE("-revertprocessedimfile", "",          DETTOOL_MODE_REVERTPROCESSEDIMFILE, revertprocessedimfileArgs);
+    PXOPT_ADD_MODE("-updateprocessedimfile", "",          DETTOOL_MODE_UPDATEPROCESSEDIMFILE, updateprocessedimfileArgs);
     PXOPT_ADD_MODE("-pendingcleanup_processedimfile", "", DETTOOL_MODE_PENDINGCLEANUP_PROCESSEDIMFILE, pendingcleanup_processedimfileArgs);
     PXOPT_ADD_MODE("-donecleanup_processedimfile", "",    DETTOOL_MODE_DONECLEANUP_PROCESSEDIMFILE, donecleanup_processedimfileArgs);
Index: trunk/ippTools/src/dettool_detrunsummary.c
===================================================================
--- trunk/ippTools/src/dettool_detrunsummary.c	(revision 23661)
+++ trunk/ippTools/src/dettool_detrunsummary.c	(revision 23688)
@@ -101,5 +101,5 @@
 
     // default values
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
     PXOPT_LOOKUP_BOOL(accept, config->args, "-accept", false);
 
@@ -107,10 +107,10 @@
             det_id,
             iteration,
-	    "full",
+            "full",
             bg,
             bg_stdev,
             bg_mean_stdev,
             accept,
-            code
+            fault
         );
 }
@@ -120,5 +120,5 @@
 {
     PS_ASSERT_PTR_NON_NULL(config, false);
-    
+
     // build a query to search by det_id, iteration, exp_id
     psMetadata *where = psMetadataAlloc();
@@ -129,6 +129,6 @@
     PXOPT_LOOKUP_BOOL(again, config->args, "-again", false);
 
-    // The values supplied as arguments on the command (eg, -bg) are parsed 
-    // by mdToDetRunSummary below. 
+    // The values supplied as arguments on the command (eg, -bg) are parsed
+    // by mdToDetRunSummary below.
     // XXX why is there ever more than one?
 
@@ -141,6 +141,6 @@
     if (psListLength(where->list)) {
         psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
-	psStringAppend(&query, " WHERE %s", whereClause);
-	psFree(whereClause);
+        psStringAppend(&query, " WHERE %s", whereClause);
+        psFree(whereClause);
     }
     psFree(where);
@@ -199,6 +199,6 @@
     psFree(output);
 
-    // XXX this logic does not deal with the case of -code being set
-    // XXX it should be an error for -again and -code to both be set
+    // XXX this logic does not deal with the case of -fault being set
+    // XXX it should be an error for -again and -fault to both be set
     if (again) {
         if (!startNewIteration(config, det_id)) {
@@ -306,5 +306,5 @@
     PXOPT_COPY_S64(config->args, where, "-det_id",    "det_id", "==");
     PXOPT_COPY_S32(config->args, where, "-iteration", "iteration", "==");
-    PXOPT_COPY_STR(config->args, where, "-code",      "fault", "==");
+    PXOPT_COPY_STR(config->args, where, "-fault",      "fault", "==");
 
     psString query = pxDataGet("dettool_revertdetrunsummary.sql");
@@ -340,5 +340,5 @@
 {
     PS_ASSERT_PTR_NON_NULL(config, false);
-    
+
     PXOPT_LOOKUP_S64(det_id, config->args, "-det_id", true, false); // required
     PXOPT_LOOKUP_BOOL(accept, config->args, "-accept", false);
@@ -355,5 +355,5 @@
     }
 
-    char *query = "UPDATE detRunSummary SET accept = %d WHERE det_id = %"PRId64; 
+    char *query = "UPDATE detRunSummary SET accept = %d WHERE det_id = %"PRId64;
     if (!p_psDBRunQueryF(config->dbh, query, accept, det_id)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
Index: trunk/ippTools/src/dettool_normalizedexp.c
===================================================================
--- trunk/ippTools/src/dettool_normalizedexp.c	(revision 23661)
+++ trunk/ippTools/src/dettool_normalizedexp.c	(revision 23688)
@@ -72,9 +72,9 @@
 {
     PS_ASSERT_PTR_NON_NULL(config, false);
-    
+
     PXOPT_LOOKUP_S64(det_id, config->args, "-det_id", true, false); // required
     PXOPT_LOOKUP_S32(iteration, config->args, "-iteration", false, false);
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
-    PXOPT_LOOKUP_STR(recipe, config->args, "-recip", (code == 0), false); // Required if code == 0
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
+    PXOPT_LOOKUP_STR(recipe, config->args, "-recip", (fault == 0), false); // Required if fault == 0
     PXOPT_LOOKUP_F64(bg, config->args, "-bg", false, false);
     PXOPT_LOOKUP_F64(bg_stdev, config->args, "-bg_stdev", false, false);
@@ -117,20 +117,20 @@
     // insert the new row into the detProcessedImfile table
     if (!detNormalizedExpInsert(
-	    config->dbh,
-	    det_id,
-	    iteration,
-	    recipe,
-	    bg,
-	    bg_stdev,
-	    bg_mean_stdev,
-	    user_1,
-	    user_2,
-	    user_3,
-	    user_4,
-	    user_5,
-	    path_base,
-	    "full",
-	    code
-	    )) {
+            config->dbh,
+            det_id,
+            iteration,
+            recipe,
+            bg,
+            bg_stdev,
+            bg_mean_stdev,
+            user_1,
+            user_2,
+            user_3,
+            user_4,
+            user_5,
+            path_base,
+            "full",
+            fault
+            )) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         return false;
@@ -221,5 +221,5 @@
     PXOPT_COPY_S64(config->args, where, "-det_id",    "det_id", "==");
     PXOPT_COPY_S32(config->args, where, "-iteration", "iteration", "==");
-    PXOPT_COPY_S16(config->args, where, "-code",      "fault", "==");
+    PXOPT_COPY_S16(config->args, where, "-fault",      "fault", "==");
 
     psString query = pxDataGet("dettool_revertnormalizedexp.sql");
@@ -260,5 +260,5 @@
 
     if (!setNormExpDataState(config, det_id, iteration, data_state)) {
-	return false;
+        return false;
     }
     return true;
Index: trunk/ippTools/src/dettool_normalizedimfile.c
===================================================================
--- trunk/ippTools/src/dettool_normalizedimfile.c	(revision 23661)
+++ trunk/ippTools/src/dettool_normalizedimfile.c	(revision 23688)
@@ -80,8 +80,8 @@
     PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false);
 
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
-
-    // Required if code == 0
-    PXOPT_LOOKUP_STR(uri, config->args, "-uri", (code == 0), false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
+
+    // Required if fault == 0
+    PXOPT_LOOKUP_STR(uri, config->args, "-uri", (fault == 0), false);
 
     // optional
@@ -97,21 +97,21 @@
 
     if (!detNormalizedImfileInsert(
-	    config->dbh,
-	    det_id,
-	    iteration,
-	    class_id,
-	    uri,
-	    bg,
-	    bg_stdev,
-	    bg_mean_stdev,
-	    user_1,
-	    user_2,
-	    user_3,
-	    user_4,
-	    user_5,
-	    path_base,
-	    "full",
-	    code
-	    )) {
+            config->dbh,
+            det_id,
+            iteration,
+            class_id,
+            uri,
+            bg,
+            bg_stdev,
+            bg_mean_stdev,
+            user_1,
+            user_2,
+            user_3,
+            user_4,
+            user_5,
+            path_base,
+            "full",
+            fault
+            )) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         return false;
@@ -201,5 +201,5 @@
     PXOPT_COPY_S32(config->args, where, "-iteration", "iteration", "==");
     PXOPT_COPY_STR(config->args, where, "-class_id",  "class_id", "==");
-    PXOPT_COPY_S16(config->args, where, "-code",      "fault", "==");
+    PXOPT_COPY_S16(config->args, where, "-fault",      "fault", "==");
 
     psString query = pxDataGet("dettool_revertnormalizedimfile.sql");
@@ -241,5 +241,5 @@
 
     if (!setNormImfileDataState(config, det_id, iteration, class_id, data_state)) {
-	return false;
+        return false;
     }
     return true;
Index: trunk/ippTools/src/dettool_normalizedstat.c
===================================================================
--- trunk/ippTools/src/dettool_normalizedstat.c	(revision 23661)
+++ trunk/ippTools/src/dettool_normalizedstat.c	(revision 23688)
@@ -83,17 +83,17 @@
     // default
     PXOPT_LOOKUP_S32(iteration, config->args, "-iteration", false, false);
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
+    PXOPT_LOOKUP_S16(code, config->args, "-fault", false, false);
 
     detNormalizedStatImfileRow *row = detNormalizedStatImfileRowAlloc
-	(det_id,
-	 iteration,
-	 class_id,
-	 norm,
-	 "full",
-	 code);
-									 
+        (det_id,
+         iteration,
+         class_id,
+         norm,
+         "full",
+         code);
+
     if (!detNormalizedStatImfileInsertObject(config->dbh, row)) {
-	psError(PS_ERR_UNKNOWN, false, "database error");
-	return false;
+        psError(PS_ERR_UNKNOWN, false, "database error");
+        return false;
     }
 
@@ -181,5 +181,5 @@
     PXOPT_COPY_S32(config->args, where, "-iteration", "iteration", "==");
     PXOPT_COPY_STR(config->args, where, "-class_id",  "class_id", "==");
-    PXOPT_COPY_S16(config->args, where, "-code",      "fault", "==");
+    PXOPT_COPY_S16(config->args, where, "-fault",      "fault", "==");
 
     psString query = pxDataGet("dettool_revertnormalizedstat.sql");
@@ -221,5 +221,5 @@
 
     if (!setNormStatImfileDataState(config, det_id, iteration, class_id, data_state)) {
-	return false;
+        return false;
     }
     return true;
Index: trunk/ippTools/src/dettool_processedexp.c
===================================================================
--- trunk/ippTools/src/dettool_processedexp.c	(revision 23661)
+++ trunk/ippTools/src/dettool_processedexp.c	(revision 23688)
@@ -80,8 +80,8 @@
 
     // default values
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
-
-    // Required if code == 0
-    PXOPT_LOOKUP_STR(recipe, config->args, "-recip", (code == 0), false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
+
+    // Required if fault == 0
+    PXOPT_LOOKUP_STR(recipe, config->args, "-recip", (fault == 0), false);
 
     // optional
@@ -141,6 +141,6 @@
         user_5,
         path_base,
-	"full",
-        code
+        "full",
+        fault
     );
 
@@ -231,5 +231,5 @@
     PXOPT_COPY_S64(config->args, where, "-det_id", "det_id", "==");
     PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "==");
-    PXOPT_COPY_S16(config->args, where, "-code",   "fault", "==");
+    PXOPT_COPY_S16(config->args, where, "-fault",   "fault", "==");
 
     psString query = pxDataGet("dettool_revertprocessedexp.sql");
@@ -269,5 +269,5 @@
     PXOPT_LOOKUP_STR(data_state, config->args, "-data_state", true, false);
     if (!setProcessedExpDataState(config, det_id, exp_id, data_state)) {
-	return false;
+        return false;
     }
     return true;
Index: trunk/ippTools/src/dettool_processedimfile.c
===================================================================
--- trunk/ippTools/src/dettool_processedimfile.c	(revision 23661)
+++ trunk/ippTools/src/dettool_processedimfile.c	(revision 23688)
@@ -92,9 +92,9 @@
 
     // default values
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
-
-    // Required if code == 0
-    PXOPT_LOOKUP_STR(uri, config->args, "-uri", (code == 0), false);
-    PXOPT_LOOKUP_STR(recipe, config->args, "-recip", (code == 0), false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
+
+    // Required if fault == 0
+    PXOPT_LOOKUP_STR(uri, config->args, "-uri", (fault == 0), false);
+    PXOPT_LOOKUP_STR(recipe, config->args, "-recip", (fault == 0), false);
 
     // optional
@@ -144,6 +144,6 @@
         user_5,
         path_base,
-	"full",
-        code
+        "full",
+        fault
     );
     psFree(rawImfiles);
@@ -190,5 +190,5 @@
         psStringAppend(&query, " %s", whereClause);
         psFree(whereClause);
-	hasWhere = true;
+        hasWhere = true;
     }
     psFree (where);
@@ -196,21 +196,21 @@
     // restrict search to included imfiles
     if (included) {
-	if (hasWhere) {
-	    psStringAppend(&query, " AND detInputExp.include = 1");
-	} else {
-	    psStringAppend(&query, " WHERE detInputExp.include = 1");
-	}
-	hasWhere = true;
+        if (hasWhere) {
+            psStringAppend(&query, " AND detInputExp.include = 1");
+        } else {
+            psStringAppend(&query, " WHERE detInputExp.include = 1");
+        }
+        hasWhere = true;
     }
 
     if (hasWhere) {
-	psStringAppend(&query, " AND");
+        psStringAppend(&query, " AND");
     } else {
-	psStringAppend(&query, " WHERE");
+        psStringAppend(&query, " WHERE");
     }
 
     if (faulted) {
         // list only faulted rows
-	psStringAppend(&query, " %s", " detProcessedImfile.fault != 0");
+        psStringAppend(&query, " %s", " detProcessedImfile.fault != 0");
     } else {
         // don't list faulted rows
@@ -263,5 +263,5 @@
     PXOPT_COPY_S64(config->args, where, "-exp_id", "exp_id", "==");
     PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "==");
-    PXOPT_COPY_S16(config->args, where, "-code", "fault", "==");
+    PXOPT_COPY_S16(config->args, where, "-fault", "fault", "==");
 
     psString query = pxDataGet("dettool_revertprocessedimfile.sql");
@@ -303,5 +303,5 @@
 
     if (!setProcessedImfileDataState(config, det_id, exp_id, class_id, data_state)) {
-	return false;
+        return false;
     }
     return true;
Index: trunk/ippTools/src/dettool_residexp.c
===================================================================
--- trunk/ippTools/src/dettool_residexp.c	(revision 23661)
+++ trunk/ippTools/src/dettool_residexp.c	(revision 23688)
@@ -95,6 +95,6 @@
     PXOPT_LOOKUP_S32(iteration, config->args, "-iteration", false, false);
     PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", true, false); // required
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
-    PXOPT_LOOKUP_STR(recipe, config->args, "-recip", (code == 0), false); // Required if code == 0
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
+    PXOPT_LOOKUP_STR(recipe, config->args, "-recip", (fault == 0), false); // Required if fault == 0
     PXOPT_LOOKUP_F64(bg, config->args, "-bg", false, false);
     PXOPT_LOOKUP_F64(bg_stdev, config->args, "-bg_stdev", false, false);
@@ -124,7 +124,7 @@
 
     if (psListLength(where->list)) {
-	psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
-	psStringAppend(&query, " WHERE %s", whereClause);
-	psFree(whereClause);
+        psString whereClause = psDBGenerateWhereConditionSQL(where, NULL);
+        psStringAppend(&query, " WHERE %s", whereClause);
+        psFree(whereClause);
     }
     psFree(where);
@@ -151,5 +151,5 @@
 
     if (!detResidExpInsert(
-	    config->dbh,
+            config->dbh,
             det_id,
             iteration,
@@ -174,7 +174,7 @@
             user_5,
             path_base,
-	    "full",
+            "full",
             !reject,
-            code
+            fault
         )) {
         psError(PS_ERR_UNKNOWN, false, "database error");
@@ -225,5 +225,5 @@
     if (reject) {
         psStringAppend(&query, " %s", "AND detResidExp.accept != 0");
-    } 
+    }
 
     // treat limit == 0 as "no limit"
@@ -273,5 +273,5 @@
     PXOPT_COPY_S32(config->args, where, "-iteration", "iteration", "==");
     PXOPT_COPY_S64(config->args, where, "-exp_id",    "exp_id", "==");
-    PXOPT_COPY_S16(config->args, where, "-code",      "fault", "==");
+    PXOPT_COPY_S16(config->args, where, "-fault",      "fault", "==");
 
     psString query = pxDataGet("dettool_revertresidexp.sql");
@@ -330,5 +330,5 @@
     PXOPT_LOOKUP_STR(data_state, config->args, "-data_state", false, false);
     if (data_state) {
-	if (!isValidDataState (data_state)) return false;
+        if (!isValidDataState (data_state)) return false;
     }
 
Index: trunk/ippTools/src/dettool_residimfile.c
===================================================================
--- trunk/ippTools/src/dettool_residimfile.c	(revision 23661)
+++ trunk/ippTools/src/dettool_residimfile.c	(revision 23688)
@@ -75,5 +75,5 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    
+
     PXOPT_LOOKUP_S64(det_id, config->args, "-det_id", true, false); // required
     PXOPT_LOOKUP_S32(iteration, config->args, "-iteration", false, false);
@@ -84,7 +84,7 @@
     PXOPT_LOOKUP_S64(exp_id, config->args, "-exp_id", true, false); // required
     PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false); // required
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
-    PXOPT_LOOKUP_STR(uri, config->args, "-uri", (code == 0), false); // Required if code == 0
-    PXOPT_LOOKUP_STR(recipe, config->args, "-recip", (code == 0), false); // Required if code == 0
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
+    PXOPT_LOOKUP_STR(uri, config->args, "-uri", (fault == 0), false); // Required if fault == 0
+    PXOPT_LOOKUP_STR(recipe, config->args, "-recip", (fault == 0), false); // Required if fault == 0
     PXOPT_LOOKUP_F64(bg, config->args, "-bg", false, false);
     PXOPT_LOOKUP_F64(bg_stdev, config->args, "-bg_stdev", false, false);
@@ -107,5 +107,5 @@
 
     if (!detResidImfileInsert(
-	    config->dbh,
+            config->dbh,
             det_id,
             iteration,
@@ -134,6 +134,6 @@
             user_5,
             path_base,
-	    "full",
-            code
+            "full",
+            fault
     )) {
         psError(PS_ERR_UNKNOWN, false, "database error");
@@ -174,5 +174,5 @@
         psStringAppend(&query, " %s", whereClause);
         psFree(whereClause);
-	hasWhere = true;
+        hasWhere = true;
     }
     psFree(where);
@@ -180,16 +180,16 @@
     // restrict search to included imfiles
     if (included) {
-	if (hasWhere) {
-	    psStringAppend(&query, " AND detInputExp.include = 1");
-	} else {
-	    psStringAppend(&query, " WHERE detInputExp.include = 1");
-	}
-	hasWhere = true;
+        if (hasWhere) {
+            psStringAppend(&query, " AND detInputExp.include = 1");
+        } else {
+            psStringAppend(&query, " WHERE detInputExp.include = 1");
+        }
+        hasWhere = true;
     }
 
     if (hasWhere) {
-	psStringAppend(&query, " AND");
+        psStringAppend(&query, " AND");
     } else {
-	psStringAppend(&query, " WHERE");
+        psStringAppend(&query, " WHERE");
     }
 
@@ -249,5 +249,5 @@
     PXOPT_COPY_S64(config->args, where, "-exp_id",  "exp_id", "==");
     PXOPT_COPY_STR(config->args, where, "-class_id",  "class_id", "==");
-    PXOPT_COPY_S16(config->args, where, "-code",      "fault", "==");
+    PXOPT_COPY_S16(config->args, where, "-fault",      "fault", "==");
 
     psString query = pxDataGet("dettool_revertresidimfile.sql");
@@ -289,5 +289,5 @@
     PXOPT_LOOKUP_STR(data_state, config->args, "-data_state", true, false);
     if (!setResidImfileDataState(config, det_id, iteration, exp_id, class_id, data_state)) {
-	return false;
+        return false;
     }
     return true;
Index: trunk/ippTools/src/dettool_stack.c
===================================================================
--- trunk/ippTools/src/dettool_stack.c	(revision 23661)
+++ trunk/ippTools/src/dettool_stack.c	(revision 23688)
@@ -127,9 +127,9 @@
     PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false);
 
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
-
-    // Required if code == 0
-    PXOPT_LOOKUP_STR(uri, config->args, "-uri", (code == 0), false);
-    PXOPT_LOOKUP_STR(recipe, config->args, "-recip", (code == 0), false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
+
+    // Required if fault == 0
+    PXOPT_LOOKUP_STR(uri, config->args, "-uri", (fault == 0), false);
+    PXOPT_LOOKUP_STR(recipe, config->args, "-recip", (fault == 0), false);
 
     // optional
@@ -188,6 +188,6 @@
             user_4,
             user_5,
-	    "full",
-            code
+            "full",
+            fault
         );
 
@@ -286,5 +286,5 @@
     PXOPT_COPY_S32(config->args, where, "-iteration", "iteration", "==");
     PXOPT_COPY_STR(config->args, where, "-class_id",  "class_id", "==");
-    PXOPT_COPY_S16(config->args, where, "-code",      "fault", "==");
+    PXOPT_COPY_S16(config->args, where, "-fault",      "fault", "==");
 
     psString query = pxDataGet("dettool_revertstacked.sql");
@@ -326,5 +326,5 @@
 
     if (!setStackedImfileDataState(config, det_id, iteration, class_id, data_state)) {
-	return false;
+        return false;
     }
     return true;
Index: trunk/ippTools/src/difftool.c
===================================================================
--- trunk/ippTools/src/difftool.c	(revision 23661)
+++ trunk/ippTools/src/difftool.c	(revision 23688)
@@ -485,7 +485,8 @@
     PXOPT_LOOKUP_S64(diff_id, config->args, "-diff_id", true, false); // required
     PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false);
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
-    PXOPT_LOOKUP_STR(uri, config->args, "-uri", (code == 0), false);
-    PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", (code == 0), false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
+    PXOPT_LOOKUP_S16(quality, config->args, "-quality", false, false);
+    PXOPT_LOOKUP_STR(uri, config->args, "-uri", (fault == 0), false);
+    PXOPT_LOOKUP_STR(path_base, config->args, "-path_base", (fault == 0), false);
 
     // optional
@@ -540,5 +541,6 @@
                            hostname,
                            good_frac,
-                           code,
+                           fault,
+                           quality,
                            magicked
           )) {
@@ -578,5 +580,5 @@
     PXOPT_COPY_S64(config->args, where,  "-diff_skyfile_id", "diffInputSkyfile.diff_skyfile_id", "==");
     PXOPT_COPY_STR(config->args, where, "-tess_id", "diffSkyfile.tess_id", "==");
-    PXOPT_COPY_S16(config->args, where, "-code", "diffSkyfile.fault", "==");
+    PXOPT_COPY_S16(config->args, where, "-fault", "diffSkyfile.fault", "==");
     PXOPT_COPY_S64(config->args, where, "-exp_id", "rawExp.exp_id", "==");
     PXOPT_COPY_STR(config->args, where, "-exp_name", "rawExp.exp_name", "==");
@@ -655,5 +657,5 @@
     PXOPT_COPY_S64(config->args, where,  "-diff_id", "diffSkyfile.diff_id", "==");
     PXOPT_COPY_STR(config->args, where,  "-label", "diffRun.label", "==");
-    PXOPT_COPY_S16(config->args, where, "-code",     "fault", "==");
+    PXOPT_COPY_S16(config->args, where, "-fault",     "fault", "==");
 
     if (!psDBTransaction(config->dbh)) {
@@ -1269,4 +1271,6 @@
     PXOPT_COPY_S64(config->args, selectWhere, "-exp_id", "inputRawExp.exp_id", "==");
     PXOPT_COPY_STR(config->args, selectWhere, "-filter", "inputRawExp.filter", "==");
+    PXOPT_COPY_STR(config->args, selectWhere, "-obs_mode", "inputRawExp.obs_mode", "==");
+    PXOPT_COPY_STR(config->args, selectWhere, "-obs_mode", "templateRawExp.obs_mode", "==");
     PXOPT_COPY_STR(config->args, selectWhere, "-input_label", "inputWarpRun.label", "==");
     PXOPT_COPY_STR(config->args, selectWhere, "-template_label", "templateWarpRun.label", "==");
@@ -1662,10 +1666,10 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    PXOPT_LOOKUP_S16(code, config->args, "-code", true, false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false);
 
     psMetadata *where = psMetadataAlloc();
     PXOPT_COPY_S64(config->args, where, "-diff_id",   "diff_id",   "==");
 
-    if (!pxSetFaultCode(config->dbh, "diffSkyfile", where, code)) {
+    if (!pxSetFaultCode(config->dbh, "diffSkyfile", where, fault)) {
         psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
         psFree (where);
Index: trunk/ippTools/src/difftoolConfig.c
===================================================================
--- trunk/ippTools/src/difftoolConfig.c	(revision 23661)
+++ trunk/ippTools/src/difftoolConfig.c	(revision 23688)
@@ -88,5 +88,6 @@
     psMetadataAddS64(adddiffskyfileArgs, PS_LIST_TAIL, "-diff_id", 0,            "define warp ID (required)", 0);
     psMetadataAddStr(adddiffskyfileArgs, PS_LIST_TAIL, "-skycell_id", 0,       "define skycell of file (required)", 0);
-    psMetadataAddS16(adddiffskyfileArgs, PS_LIST_TAIL, "-code",  0,            "set fault code", 0);
+    psMetadataAddS16(adddiffskyfileArgs, PS_LIST_TAIL, "-fault",  0,            "set fault code", 0);
+    psMetadataAddS16(adddiffskyfileArgs, PS_LIST_TAIL, "-quality",  0,            "set quality", 0);
     psMetadataAddStr(adddiffskyfileArgs, PS_LIST_TAIL, "-uri", 0,            "define URI of file", 0);
     psMetadataAddStr(adddiffskyfileArgs, PS_LIST_TAIL, "-path_base", 0,            "define base output location", 0);
@@ -123,5 +124,5 @@
     psMetadataAddU64(diffskyfileArgs, PS_LIST_TAIL, "-limit",  0,            "limit result set to N items", 0);
     psMetadataAddBool(diffskyfileArgs, PS_LIST_TAIL, "-simple",  0,            "use the simple output format", false);
-    psMetadataAddS16(diffskyfileArgs, PS_LIST_TAIL, "-code",  0,            "deifine fault code", 0);
+    psMetadataAddS16(diffskyfileArgs, PS_LIST_TAIL, "-fault",  0,            "define fault code", 0);
 
     // -revertdiffskyfile
@@ -129,5 +130,5 @@
     psMetadataAddS64(revertdiffskyfileArgs, PS_LIST_TAIL, "-diff_id", 0,            "search by diff ID", 0);
     psMetadataAddStr(revertdiffskyfileArgs, PS_LIST_TAIL, "-label", 0, "search by label", NULL);
-    psMetadataAddS16(revertdiffskyfileArgs, PS_LIST_TAIL, "-code",  0,            "search by fault code", 0);
+    psMetadataAddS16(revertdiffskyfileArgs, PS_LIST_TAIL, "-fault",  0,            "search by fault code", 0);
 
     // -definepoprun
@@ -171,4 +172,5 @@
     psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-filter", 0, "search by filter", NULL);
     psMetadataAddF32(definewarpwarpArgs, PS_LIST_TAIL, "-distance", 0, "limit distance between input and template (deg)", NAN);
+    psMetadataAddStr(definewarpwarpArgs, PS_LIST_TAIL, "-obs_mode", 0, "search by observation mode", NULL);
     psMetadataAddF32(definewarpwarpArgs, PS_LIST_TAIL, "-timediff", 0, "limit time difference between input and template", NAN);
     psMetadataAddF32(definewarpwarpArgs, PS_LIST_TAIL, "-rotdiff", 0, "limit rotator difference between input and template", NAN);
@@ -205,5 +207,5 @@
     psMetadata *updatediffskyfileArgs = psMetadataAlloc();
     psMetadataAddS64(updatediffskyfileArgs, PS_LIST_TAIL, "-diff_id", 0,      "define diff ID (required)", 0);
-    psMetadataAddS16(updatediffskyfileArgs, PS_LIST_TAIL, "-code", 0,         "set fault code (required)", 0);
+    psMetadataAddS16(updatediffskyfileArgs, PS_LIST_TAIL, "-fault", 0,         "set fault code (required)", 0);
 
     // -exportrun
Index: trunk/ippTools/src/disttool.c
===================================================================
--- trunk/ippTools/src/disttool.c	(revision 23661)
+++ trunk/ippTools/src/disttool.c	(revision 23688)
@@ -106,5 +106,5 @@
 
     // TODO: should we check that stage_id actually exists for stage
-    // in magicdstool we queue off of a magic_id so the stage_id, exp_id, and cam_id get looked up 
+    // in magicdstool we queue off of a magic_id so the stage_id, exp_id, and cam_id get looked up
     // when the run is queued
 
@@ -151,8 +151,8 @@
     PXOPT_LOOKUP_STR(state, config->args, "-set_state", false, false);
     PXOPT_LOOKUP_STR(label, config->args, "-set_label", false, false);
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
-
-    if ((!state) && (!label) && (!code)) {
-        psError(PXTOOLS_ERR_DATA, false, "parameters (-code or -set_state or -set_label) are required");
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
+
+    if ((!state) && (!label) && (!fault)) {
+        psError(PXTOOLS_ERR_DATA, false, "parameters (-fault or -set_state or -set_label) are required");
         psFree(where);
         return false;
@@ -169,6 +169,6 @@
     }
 
-    if (code) {
-        psStringAppend(&query, " , fault = %d", code);
+    if (fault) {
+        psStringAppend(&query, " , fault = %d", fault);
     }
 
@@ -195,5 +195,5 @@
     PXOPT_COPY_STR(config->args, where, "-state", "state", "==");
     PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
-    PXOPT_COPY_S16(config->args, where, "-code", "distComponent.fault", "==");
+    PXOPT_COPY_S16(config->args, where, "-fault", "distComponent.fault", "==");
 
     // It might be useful to be able to query by the parameters of the underlying runs
@@ -402,6 +402,6 @@
     // unless fault code is set require filename, bytes, and md5sum
     bool require_fileinfo = false;
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
-    if (!code) {
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
+    if (!fault) {
         require_fileinfo = true;
     }
@@ -410,5 +410,5 @@
     PXOPT_LOOKUP_STR(name, config->args, "-name", require_fileinfo, false);
 
-    if (!distComponentInsert(config->dbh, dist_id, component, bytes, md5sum, "full", name, code)) {
+    if (!distComponentInsert(config->dbh, dist_id, component, bytes, md5sum, "full", name, fault)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         return false;
Index: trunk/ippTools/src/disttoolConfig.c
===================================================================
--- trunk/ippTools/src/disttoolConfig.c	(revision 23661)
+++ trunk/ippTools/src/disttoolConfig.c	(revision 23688)
@@ -46,5 +46,5 @@
     psMetadata *definerunArgs = psMetadataAlloc();
     psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-stage",         0, "define stage for bundle (required)", NULL);
-    psMetadataAddS64(definerunArgs, PS_LIST_TAIL, "-stage_id", 0, "define stage_id (required)", 0); 
+    psMetadataAddS64(definerunArgs, PS_LIST_TAIL, "-stage_id", 0, "define stage_id (required)", 0);
     psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-outroot",  0, "define output destination (required)", NULL);
     psMetadataAddS64(definerunArgs, PS_LIST_TAIL, "-target_id", 0, "define stage_id", 0); 
@@ -52,8 +52,8 @@
     psMetadataAddBool(definerunArgs, PS_LIST_TAIL, "-no_magic", 0, "magic is not needed", false);
     psMetadataAddStr(definerunArgs, PS_LIST_TAIL, "-set_label",    0, "define label for run", NULL);
-    
+
     // -updaterun
     psMetadata *updaterunArgs = psMetadataAlloc();
-    psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-dist_id",  0, "define dist_id", 0); 
+    psMetadataAddS64(updaterunArgs, PS_LIST_TAIL, "-dist_id",  0, "define dist_id", 0);
     psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_state", 0, "new value for state", NULL);
     psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-set_label", 0, "new value for label", NULL);
@@ -61,19 +61,19 @@
     psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-state",     0, "value for state", NULL);
     psMetadataAddStr(updaterunArgs, PS_LIST_TAIL, "-label",     0, "limit updates to label", NULL);
-    psMetadataAddS16(updaterunArgs, PS_LIST_TAIL, "-code",      0, "define fault code", 0); 
-    
+    psMetadataAddS16(updaterunArgs, PS_LIST_TAIL, "-fault",      0, "define fault code", 0);
+
     // -revertrun
     psMetadata *revertrunArgs = psMetadataAlloc();
-    psMetadataAddS64(revertrunArgs, PS_LIST_TAIL, "-dist_id", 0, "define dist_id", 0); 
+    psMetadataAddS64(revertrunArgs, PS_LIST_TAIL, "-dist_id", 0, "define dist_id", 0);
     psMetadataAddStr(revertrunArgs, PS_LIST_TAIL, "-stage",    0, "define stage", NULL);
-    psMetadataAddS64(revertrunArgs, PS_LIST_TAIL, "-stage_id", 0, "define stage_id", 0); 
+    psMetadataAddS64(revertrunArgs, PS_LIST_TAIL, "-stage_id", 0, "define stage_id", 0);
     psMetadataAddStr(revertrunArgs, PS_LIST_TAIL, "-state",    0, "define state", NULL);
     psMetadataAddStr(revertrunArgs, PS_LIST_TAIL, "-label",    0, "define label", NULL);
-    psMetadataAddS16(revertrunArgs, PS_LIST_TAIL, "-code", 0, "define fault code", 0); 
+    psMetadataAddS16(revertrunArgs, PS_LIST_TAIL, "-fault", 0, "define fault code", 0);
     psMetadataAddBool(revertrunArgs, PS_LIST_TAIL, "-all",    0, "revert all faulted runs", NULL);
-    
+
     // -pendingcomponent
     psMetadata *pendingcomponentArgs = psMetadataAlloc();
-    psMetadataAddS64(pendingcomponentArgs, PS_LIST_TAIL, "-dist_id", 0, "define dist_id", 0); 
+    psMetadataAddS64(pendingcomponentArgs, PS_LIST_TAIL, "-dist_id", 0, "define dist_id", 0);
     psMetadataAddStr(pendingcomponentArgs, PS_LIST_TAIL, "-stage",    0, "limit results to runs for stage", NULL);
     psMetadataAddStr(pendingcomponentArgs, PS_LIST_TAIL, "-label",    0, "limit results to label", NULL);
@@ -84,14 +84,14 @@
     // -addprocessedcomponent
     psMetadata *addprocessedcomponentArgs = psMetadataAlloc();
-    psMetadataAddS64(addprocessedcomponentArgs, PS_LIST_TAIL, "-dist_id", 0, "define dist_id", 0); 
+    psMetadataAddS64(addprocessedcomponentArgs, PS_LIST_TAIL, "-dist_id", 0, "define dist_id", 0);
     psMetadataAddStr(addprocessedcomponentArgs, PS_LIST_TAIL, "-component", 0, "define component (required)", NULL);
     psMetadataAddStr(addprocessedcomponentArgs, PS_LIST_TAIL, "-name", 0, "define file name", NULL);
-    psMetadataAddS32(addprocessedcomponentArgs, PS_LIST_TAIL, "-bytes", 0, "define file size", 0); 
+    psMetadataAddS32(addprocessedcomponentArgs, PS_LIST_TAIL, "-bytes", 0, "define file size", 0);
     psMetadataAddStr(addprocessedcomponentArgs, PS_LIST_TAIL, "-md5sum", 0, "define stage for bundle", NULL);
-    psMetadataAddS32(addprocessedcomponentArgs, PS_LIST_TAIL, "-code", 0, "define fault code", 0); 
+    psMetadataAddS32(addprocessedcomponentArgs, PS_LIST_TAIL, "-fault", 0, "define fault code", 0);
 
     // -processedcomponent
     psMetadata *processedcomponentArgs = psMetadataAlloc();
-    psMetadataAddS64(processedcomponentArgs, PS_LIST_TAIL, "-dist_id", 0, "define dist_id", 0); 
+    psMetadataAddS64(processedcomponentArgs, PS_LIST_TAIL, "-dist_id", 0, "define dist_id", 0);
     psMetadataAddU64(processedcomponentArgs, PS_LIST_TAIL, "-limit",  0,  "limit result set to N items", 0);
     psMetadataAddBool(processedcomponentArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);
@@ -99,5 +99,5 @@
     // -toadvance
     psMetadata *toadvanceArgs = psMetadataAlloc();
-    psMetadataAddS64(toadvanceArgs, PS_LIST_TAIL, "-dist_id", 0, "define dist_id", 0); 
+    psMetadataAddS64(toadvanceArgs, PS_LIST_TAIL, "-dist_id", 0, "define dist_id", 0);
     psMetadataAddU64(toadvanceArgs, PS_LIST_TAIL, "-limit",  0,  "limit result set to N items", 0);
     psMetadataAddBool(toadvanceArgs, PS_LIST_TAIL, "-simple", 0, "use the simple output format", false);
Index: trunk/ippTools/src/faketool.c
===================================================================
--- trunk/ippTools/src/faketool.c	(revision 23661)
+++ trunk/ippTools/src/faketool.c	(revision 23688)
@@ -496,5 +496,5 @@
 
     // default values
-    PXOPT_LOOKUP_S16(code, config->args,        "-code", false, false);
+    PXOPT_LOOKUP_S16(fault, config->args,        "-fault", false, false);
 
     if (!psDBTransaction(config->dbh)) {
@@ -513,5 +513,5 @@
                                    path_base,
                                    "full",
-                                   code,
+                                   fault,
                                    NULL         // epoch
             )) {
@@ -687,5 +687,5 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    PXOPT_LOOKUP_S16(code, config->args, "-code", true, false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false);
 
     psMetadata *where = psMetadataAlloc();
@@ -693,5 +693,5 @@
     PXOPT_COPY_STR(config->args, where, "-class_id", "class_id", "==");
 
-    if (!pxSetFaultCode(config->dbh, "fakeProcessedImfile", where, code)) {
+    if (!pxSetFaultCode(config->dbh, "fakeProcessedImfile", where, fault)) {
         psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
         psFree(where);
@@ -1238,5 +1238,5 @@
 
   int numExportTables = 2;
-  
+
   PS_ASSERT_PTR_NON_NULL(config, NULL);
 
@@ -1316,5 +1316,5 @@
 
   PS_ASSERT_PTR_NON_NULL(config, NULL);
-  
+
   PXOPT_LOOKUP_STR(infile, config->args, "-infile", true,  false);
 
Index: trunk/ippTools/src/faketoolConfig.c
===================================================================
--- trunk/ippTools/src/faketoolConfig.c	(revision 23661)
+++ trunk/ippTools/src/faketoolConfig.c	(revision 23688)
@@ -175,5 +175,5 @@
     psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-hostname",  0,            "define hostname", NULL);
     psMetadataAddStr(addprocessedimfileArgs, PS_LIST_TAIL, "-path_base",  0,            "define base output location", NULL);
-    psMetadataAddS16(addprocessedimfileArgs, PS_LIST_TAIL, "-code",  0,            "set fault code", 0);
+    psMetadataAddS16(addprocessedimfileArgs, PS_LIST_TAIL, "-fault",  0,            "set fault code", 0);
 
     // -processedimfile
@@ -193,5 +193,5 @@
     psMetadataAddS64(updateprocessedimfileArgs, PS_LIST_TAIL, "-exp_id",  0,            "search by exposure ID", 0);
     psMetadataAddStr(updateprocessedimfileArgs, PS_LIST_TAIL, "-class_id",  0,            "search by class ID", NULL);
-    psMetadataAddS16(updateprocessedimfileArgs, PS_LIST_TAIL, "-code",  0,            "set fault code (required)", 0);
+    psMetadataAddS16(updateprocessedimfileArgs, PS_LIST_TAIL, "-fault",  0,            "set fault code (required)", 0);
 
     // -revertprocessedimfile
@@ -239,5 +239,5 @@
 
     psMetadataAddBool(revertprocessedimfileArgs, PS_LIST_TAIL, "-all",  0,            "allow everything to be queued without search terms", false);
-    psMetadataAddS16(revertprocessedimfileArgs, PS_LIST_TAIL, "-code",  0,            "search by fault code", 0);
+    psMetadataAddS16(revertprocessedimfileArgs, PS_LIST_TAIL, "-fault",  0,            "search by fault code", 0);
 
 
Index: trunk/ippTools/src/flatcorr.c
===================================================================
--- trunk/ippTools/src/flatcorr.c	(revision 23661)
+++ trunk/ippTools/src/flatcorr.c	(revision 23688)
@@ -117,5 +117,5 @@
     }
 
-    // require the camera to be defined: this analysis does not make sense 
+    // require the camera to be defined: this analysis does not make sense
     // across multiple cameras
     PXOPT_LOOKUP_STR(camera, config->args, "-inst", true, false);
@@ -169,12 +169,12 @@
 
     if (pretend) {
-	for (long i = 0; i < psArrayLength(output); i++) {
-	    // negative simple so the default is true
-	    if (!ippdbPrintMetadataRaw(stdout, output->data[i], !simple)) {
-		psError(PS_ERR_UNKNOWN, false, "failed to print array");
-		psFree(output);
-		return false;
-	    }
-	}
+        for (long i = 0; i < psArrayLength(output); i++) {
+            // negative simple so the default is true
+            if (!ippdbPrintMetadataRaw(stdout, output->data[i], !simple)) {
+                psError(PS_ERR_UNKNOWN, false, "failed to print array");
+                psFree(output);
+                return false;
+            }
+        }
         psFree(output);
         return true;
@@ -191,11 +191,11 @@
     // create a new flatcorrRun
     if (!flatcorrRunInsert(
-	    config->dbh,
+            config->dbh,
             0,      // corr_id
-	    det_type,
+            det_type,
             dvodb,
-	    camera,
-	    telescope,
-	    NULL,
+            camera,
+            telescope,
+            NULL,
             filter,
             "reg",  // state
@@ -203,7 +203,7 @@
             label,
             reduction,
-	    region,
-	    NULL,
-	    0
+            region,
+            NULL,
+            0
         )) {
         if (!psDBRollback(config->dbh)) {
@@ -304,18 +304,18 @@
     // create a new flatcorrRun
     flatcorrRunRow *row = flatcorrRunRowAlloc(
-	0,      // corr_id
-	det_type,
-	dvodb,
-	camera,
-	telescope,
-	NULL,
-	filter,
-	"reg",  // state
-	workdir,
-	label,
-	reduction,
-	region,
-	NULL, // hostname
-	0 // fault
+        0,      // corr_id
+        det_type,
+        dvodb,
+        camera,
+        telescope,
+        NULL,
+        filter,
+        "reg",  // state
+        workdir,
+        label,
+        reduction,
+        region,
+        NULL, // hostname
+        0 // fault
         );
 
@@ -328,5 +328,5 @@
         return false;
     }
-    
+
     // figure out the ID of the flatcorrRun we just created
     psS64 corr_id = psDBLastInsertID(config->dbh);
@@ -365,6 +365,6 @@
     psString query = pxDataGet("flatcorr_dropchip.sql");
     if (!query) {
-	psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
-	return false;
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
+        return false;
     }
 
@@ -390,13 +390,13 @@
     psString query = pxDataGet("flatcorr_chiprundone.sql");
     if (!query) {
-	psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
-	return false;
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
+        return false;
     }
 
     // treat limit == 0 as "no limit"
     if (limit) {
-	psString limitString = psDBGenerateLimitSQL(limit);
-	psStringAppend(&query, " %s", limitString);
-	psFree(limitString);
+        psString limitString = psDBGenerateLimitSQL(limit);
+        psStringAppend(&query, " %s", limitString);
+        psFree(limitString);
     }
 
@@ -459,13 +459,13 @@
         // queue the exp
         if (!pxcamQueueByChipID(
-		config,
-		row->chip_id,
-		row->workdir,
-		row->label,
-		row->reduction,
-		row->expgroup,
-		row->dvodb,
-		row->tess_id,
-		"camera")) {
+                config,
+                row->chip_id,
+                row->workdir,
+                row->label,
+                row->reduction,
+                row->expgroup,
+                row->dvodb,
+                row->tess_id,
+                "camera")) {
             if (!psDBRollback(config->dbh)) {
                 psError(PS_ERR_UNKNOWN, false, "database error");
@@ -478,8 +478,8 @@
         }
 
-	// figure out the ID of the flatcorrRun we just created
-	psS64 cam_id = psDBLastInsertID(config->dbh);
-
-	// add the camRun entry to the flatcorrCamLink table (include is TRUE)
+        // figure out the ID of the flatcorrRun we just created
+        psS64 cam_id = psDBLastInsertID(config->dbh);
+
+        // add the camRun entry to the flatcorrCamLink table (include is TRUE)
         if (!flatcorrCamLinkInsert(config->dbh, corr_id, row->chip_id, cam_id, 1)) {
             if (!psDBRollback(config->dbh)) {
@@ -489,5 +489,5 @@
             return false;
         }
-	
+
         psFree(row);
     }
@@ -513,6 +513,6 @@
     psString query = pxDataGet("flatcorr_dropcamera.sql");
     if (!query) {
-	psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
-	return false;
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
+        return false;
     }
 
@@ -537,13 +537,13 @@
     psString query = pxDataGet("flatcorr_pendingprocess.sql");
     if (!query) {
-	psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
-	return false;
+        psError(PXTOOLS_ERR_DATA, false, "failed to retreive SQL statement");
+        return false;
     }
 
     // treat limit == 0 as "no limit"
     if (limit) {
-	psString limitString = psDBGenerateLimitSQL(limit);
-	psStringAppend(&query, " %s", limitString);
-	psFree(limitString);
+        psString limitString = psDBGenerateLimitSQL(limit);
+        psStringAppend(&query, " %s", limitString);
+        psFree(limitString);
     }
 
@@ -566,7 +566,7 @@
 
     if (!ippdbPrintMetadatas(stdout, output, "flatcorrPending", !simple)) {
-	psError(PS_ERR_UNKNOWN, false, "failed to print array");
-	psFree(output);
-	return false;
+        psError(PS_ERR_UNKNOWN, false, "failed to print array");
+        psFree(output);
+        return false;
     }
 
@@ -588,7 +588,7 @@
     // treat limit == 0 as "no limit"
     if (limit) {
-	psString limitString = psDBGenerateLimitSQL(limit);
-	psStringAppend(&query, " %s", limitString);
-	psFree(limitString);
+        psString limitString = psDBGenerateLimitSQL(limit);
+        psStringAppend(&query, " %s", limitString);
+        psFree(limitString);
     }
 
@@ -611,7 +611,7 @@
 
     if (!ippdbPrintMetadatas(stdout, output, "flatcorrPending", !simple)) {
-	psError(PS_ERR_UNKNOWN, false, "failed to print array");
-	psFree(output);
-	return false;
+        psError(PS_ERR_UNKNOWN, false, "failed to print array");
+        psFree(output);
+        return false;
     }
 
@@ -628,5 +628,5 @@
     PXOPT_LOOKUP_BOOL(simple,  config->args, "-simple",  false);
     PXOPT_LOOKUP_BOOL(limit,   config->args, "-limit",   false);
-    
+
     psMetadata *where = psMetadataAlloc();
     PXOPT_COPY_S64(config->args, where, "-chip_id", "chipProcessedImfile.chip_id", "==");
@@ -647,7 +647,7 @@
     // treat limit == 0 as "no limit"
     if (limit) {
-	psString limitString = psDBGenerateLimitSQL(limit);
-	psStringAppend(&query, " %s", limitString);
-	psFree(limitString);
+        psString limitString = psDBGenerateLimitSQL(limit);
+        psStringAppend(&query, " %s", limitString);
+        psFree(limitString);
     }
 
@@ -670,7 +670,7 @@
 
     if (!ippdbPrintMetadatas(stdout, output, "flatcorrPending", !simple)) {
-	psError(PS_ERR_UNKNOWN, false, "failed to print array");
-	psFree(output);
-	return false;
+        psError(PS_ERR_UNKNOWN, false, "failed to print array");
+        psFree(output);
+        return false;
     }
 
@@ -685,9 +685,9 @@
     PXOPT_LOOKUP_S64(corr_id, config->args, "-corr_id", true, false);
     PXOPT_LOOKUP_STR(hostname, config->args, "-hostname", false, false);
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
 
     char *query = "UPDATE flatcorrRun SET state = 'full', hostname = '%s', fault = '%hd' WHERE corr_id = %" PRId64;
 
-    if (!p_psDBRunQueryF(config->dbh, query, hostname, code, corr_id)) {
+    if (!p_psDBRunQueryF(config->dbh, query, hostname, fault, corr_id)) {
         psError(PS_ERR_UNKNOWN, false, "failed to change state for corr_id %" PRId64, corr_id);
         return false;
@@ -721,7 +721,7 @@
 
     // check that state is a valid string value
-    if (!strcmp(state, "reg") && 
-	!strcmp(state, "new") && 
-	!strcmp(state, "full"))
+    if (!strcmp(state, "reg") &&
+        !strcmp(state, "new") &&
+        !strcmp(state, "full"))
     {
         psError(PS_ERR_UNKNOWN, false, "invalid state: %s", state);
@@ -745,5 +745,5 @@
     char sqlFilename[80];
   } ExportTable;
-  
+
   int numExportTables = 3;
 
@@ -825,11 +825,11 @@
   unsigned int nFail;
   psMetadataItem *item, *entry;
-  
+
   int numImportTables = 3;
-  
+
   char tables[3] [80] = {"flatcorrRun", "flatcorrCamLink", "flatcorrChipLink"};
 
   PS_ASSERT_PTR_NON_NULL(config, NULL);
-  
+
   PXOPT_LOOKUP_STR(infile, config->args, "-infile", true,  false);
 
@@ -843,9 +843,9 @@
     psAssert (item, "entry not in input?");
     psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");
-    
+
     entry = psListGet (item->data.list, 0);
     assert (entry);
     assert (entry->type == PS_DATA_METADATA);
-  
+
     switch (i) {
       case 0:
@@ -857,5 +857,5 @@
         // psMetadataPrint (stderr, entry->data.md, 1);
         break;
-      } 
+      }
       case 1:
       {
Index: trunk/ippTools/src/flatcorrConfig.c
===================================================================
--- trunk/ippTools/src/flatcorrConfig.c	(revision 23661)
+++ trunk/ippTools/src/flatcorrConfig.c	(revision 23688)
@@ -106,5 +106,5 @@
     psMetadataAddS64 (addprocessArgs, PS_LIST_TAIL, "-corr_id",  0, "add complete run for specified corr_id (required)", 0);
     psMetadataAddStr (addprocessArgs, PS_LIST_TAIL, "-hostname", 0, "set hostname", NULL);
-    psMetadataAddS16 (addprocessArgs, PS_LIST_TAIL, "-code",     0, "set fault code", 0);
+    psMetadataAddS16 (addprocessArgs, PS_LIST_TAIL, "-fault",     0, "set fault code", 0);
 
     // -updaterun
Index: trunk/ippTools/src/magicdstool.c
===================================================================
--- trunk/ippTools/src/magicdstool.c	(revision 23661)
+++ trunk/ippTools/src/magicdstool.c	(revision 23688)
@@ -599,10 +599,10 @@
 
     // default values
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
     PXOPT_LOOKUP_STR(backup_path_base, config->args, "-backup_path_base", false, false);
     PXOPT_LOOKUP_STR(recovery_path_base, config->args, "-recovery_path_base", false, false);
     PXOPT_LOOKUP_BOOL(setmagicked, config->args, "-setmagicked", false);
 
-    if (setmagicked && (code != 0)) {
+    if (setmagicked && (fault != 0)) {
         psError(PS_ERR_UNKNOWN, true, " cannot setmagicked for faulted file");
         return false;
@@ -625,5 +625,5 @@
     }
 
-    if (!magicDSFileInsert(config->dbh, magic_ds_id, component, backup_path_base, recovery_path_base, code)) {
+    if (!magicDSFileInsert(config->dbh, magic_ds_id, component, backup_path_base, recovery_path_base, fault)) {
             // rollback
         if (!psDBRollback(config->dbh)) {
@@ -781,5 +781,5 @@
     PXOPT_COPY_S64(config->args, where, "-magic_ds_id", "magic_ds_id", "==");
     PXOPT_COPY_STR(config->args, where, "-component", "component", "==");
-    PXOPT_COPY_S16(config->args, where, "-code", "fault", "==");
+    PXOPT_COPY_S16(config->args, where, "-fault", "fault", "==");
 
     psString query = psStringCopy("DELETE FROM magicDSFile WHERE fault != 0");
Index: trunk/ippTools/src/magicdstoolConfig.c
===================================================================
--- trunk/ippTools/src/magicdstoolConfig.c	(revision 23661)
+++ trunk/ippTools/src/magicdstoolConfig.c	(revision 23688)
@@ -99,5 +99,5 @@
     psMetadataAddStr(adddestreakedfileArgs, PS_LIST_TAIL, "-recovery_path_base", 0, "define recovery pixels URI", NULL);
     psMetadataAddBool(adddestreakedfileArgs, PS_LIST_TAIL, "-setmagicked", 0, "update the magicked state of the file", false);
-    psMetadataAddS16(adddestreakedfileArgs, PS_LIST_TAIL, "-code", 0, "set fault code", 0);
+    psMetadataAddS16(adddestreakedfileArgs, PS_LIST_TAIL, "-fault", 0, "set fault code", 0);
 
     // -revertdestreakedfile
@@ -105,5 +105,5 @@
     psMetadataAddS64(revertdestreakedfileArgs, PS_LIST_TAIL, "-magic_ds_id", 0, "search by magictool de-streak ID", 0);
     psMetadataAddStr(revertdestreakedfileArgs, PS_LIST_TAIL, "-component", 0, "search by component", NULL);
-    psMetadataAddS16(revertdestreakedfileArgs, PS_LIST_TAIL, "-code", 0, "search by fault code", 0);
+    psMetadataAddS16(revertdestreakedfileArgs, PS_LIST_TAIL, "-fault", 0, "search by fault code", 0);
 
     // -getskycells
@@ -125,5 +125,5 @@
     PXOPT_ADD_MODE("-updaterun",           "update state of magic de-streak run",
                     MAGICDSTOOL_MODE_UPDATERUN,         updaterunArgs);
-    PXOPT_ADD_MODE("-todestreak",          "show pending files",    
+    PXOPT_ADD_MODE("-todestreak",          "show pending files",
                     MAGICDSTOOL_MODE_TODESTREAK,       todestreakArgs);
     PXOPT_ADD_MODE("-adddestreakedfile",   "add a de-streaked file",
Index: trunk/ippTools/src/magictool.c
===================================================================
--- trunk/ippTools/src/magictool.c	(revision 23661)
+++ trunk/ippTools/src/magictool.c	(revision 23688)
@@ -535,9 +535,9 @@
 
     // default values
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
-
-    if (code > 0) {
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
+
+    if (fault > 0) {
         char *query = "UPDATE magicRun SET fault = %d, state = 'full' WHERE magic_id = %" PRId64;
-        if (!p_psDBRunQueryF(config->dbh, query, code, magic_id)) {
+        if (!p_psDBRunQueryF(config->dbh, query, fault, magic_id)) {
             psError(PS_ERR_UNKNOWN, false,
                     "failed to set fault for magic_id %" PRId64, magic_id);
@@ -561,5 +561,5 @@
     psMetadata *where = psMetadataAlloc();
     PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "==");
-    PXOPT_COPY_S16(config->args, where, "-code", "fault", "==");
+    PXOPT_COPY_S16(config->args, where, "-fault", "fault", "==");
 
     psString query = psStringCopy("UPDATE magicRun SET fault = 0, state = 'run' WHERE fault != 0");
@@ -908,5 +908,5 @@
 
     // default values
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
 
     if (!magicNodeResultInsert(config->dbh,
@@ -914,5 +914,5 @@
                                node,
                                uri,
-                               code
+                               fault
         )) {
         psError(PS_ERR_UNKNOWN, false, "database error");
@@ -931,5 +931,5 @@
     PXOPT_COPY_STR(config->args, where, "-node", "node", "==");
     PXOPT_COPY_STR(config->args, where, "-label", "label", "==");
-    PXOPT_COPY_S16(config->args, where, "-code", "magicNodeResult.fault", "==");
+    PXOPT_COPY_S16(config->args, where, "-fault", "fault", "==");
 
     psString query = pxDataGet("magictool_revertnode.sql");
@@ -1037,5 +1037,5 @@
 
     // default values
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
 
     if (!psDBTransaction(config->dbh)) {
@@ -1048,5 +1048,5 @@
                          uri,
                          streaks,
-                         code
+                         fault
         )) {
         psError(PS_ERR_UNKNOWN, false, "database error");
@@ -1094,5 +1094,5 @@
     psMetadata *where = psMetadataAlloc();
     PXOPT_COPY_S64(config->args, where, "-magic_id", "magic_id", "==");
-    PXOPT_COPY_S16(config->args, where, "-code", "fault", "==");
+    PXOPT_COPY_S16(config->args, where, "-fault", "fault", "==");
 
     if (!psDBTransaction(config->dbh)) {
Index: trunk/ippTools/src/magictoolConfig.c
===================================================================
--- trunk/ippTools/src/magictoolConfig.c	(revision 23661)
+++ trunk/ippTools/src/magictoolConfig.c	(revision 23688)
@@ -100,10 +100,10 @@
     psMetadataAddS64(inputtreeArgs, PS_LIST_TAIL, "-magic_id", 0, "define magictool ID (required)", 0);
     psMetadataAddStr(inputtreeArgs, PS_LIST_TAIL, "-dep_file", 0, "order of operations dep. file", NULL);
-    psMetadataAddS16(inputtreeArgs, PS_LIST_TAIL, "-code", 0, "set fault code", 0);
+    psMetadataAddS16(inputtreeArgs, PS_LIST_TAIL, "-fault", 0, "set fault code", 0);
 
     // -reverttree
     psMetadata *reverttreeArgs = psMetadataAlloc();
     psMetadataAddS64(reverttreeArgs, PS_LIST_TAIL, "-magic_id", 0, "search by magictool ID", 0);
-    psMetadataAddS16(reverttreeArgs, PS_LIST_TAIL, "-code", 0, "search by fault code", 0);
+    psMetadataAddS16(reverttreeArgs, PS_LIST_TAIL, "-fault", 0, "search by fault code", 0);
 
     // -inputs
@@ -126,5 +126,5 @@
     psMetadataAddStr(addresultArgs, PS_LIST_TAIL, "-node", 0, "define symbolic node name (required)", NULL);
     psMetadataAddStr(addresultArgs, PS_LIST_TAIL, "-uri", 0, "define URI", NULL);
-    psMetadataAddS16(addresultArgs, PS_LIST_TAIL, "-code", 0, "set fault code", 0);
+    psMetadataAddS16(addresultArgs, PS_LIST_TAIL, "-fault", 0, "set fault code", 0);
 
     // -revertnode
@@ -133,5 +133,5 @@
     psMetadataAddStr(revertnodeArgs, PS_LIST_TAIL, "-node", 0, "search by node name", NULL);
     psMetadataAddStr(revertnodeArgs, PS_LIST_TAIL, "-label",0, "search by label", NULL);
-    psMetadataAddS16(revertnodeArgs, PS_LIST_TAIL, "-code", 0, "search by fault code", 0);
+    psMetadataAddS16(revertnodeArgs, PS_LIST_TAIL, "-fault", 0, "search by fault code", 0);
 
     // -tomask
@@ -145,10 +145,10 @@
     psMetadataAddStr(addmaskArgs, PS_LIST_TAIL, "-uri", 0, "define URI", NULL);
     psMetadataAddS32(addmaskArgs, PS_LIST_TAIL, "-streaks", 0, "define number of streaks", 0);
-    psMetadataAddS16(addmaskArgs, PS_LIST_TAIL, "-code", 0, "set fault code", 0);
+    psMetadataAddS16(addmaskArgs, PS_LIST_TAIL, "-fault", 0, "set fault code", 0);
 
     // -revertmask
     psMetadata *revertmaskArgs = psMetadataAlloc();
     psMetadataAddS64(revertmaskArgs, PS_LIST_TAIL, "-magic_id", 0, "search by magictool ID", 0);
-    psMetadataAddS16(revertmaskArgs, PS_LIST_TAIL, "-code", 0, "search by fault code", 0);
+    psMetadataAddS16(revertmaskArgs, PS_LIST_TAIL, "-fault", 0, "search by fault code", 0);
 
     // -mask
Index: trunk/ippTools/src/pztool.c
===================================================================
--- trunk/ippTools/src/pztool.c	(revision 23661)
+++ trunk/ippTools/src/pztool.c	(revision 23688)
@@ -338,5 +338,5 @@
         // a lot simplier than a complicated scheme (tried that) to attempt to
         // request on the right number of rows for each camera
-        
+
         // treat limit == 0 as "no limit"
         if (limit) {
@@ -403,5 +403,5 @@
 
     // default values
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
 
     // start a transaction early so it will contain any row level locks
@@ -410,5 +410,5 @@
         return false;
     }
-    
+
     // query to get an excluse lock on this exposure in
     // pzDownloadExp
@@ -421,5 +421,5 @@
         PXOPT_COPY_STR(config->args, where,  "-inst", "camera", "==");
         PXOPT_COPY_STR(config->args, where,  "-telescope", "telescope", "==");
-        
+
         if (psListLength(where->list)) {
             psString whereClause = psDBGenerateWhereSQL(where, NULL);
@@ -455,5 +455,5 @@
             class_id,
             uri,
-            code,
+            fault,
             NULL,    // epoch
             hostname
@@ -605,5 +605,5 @@
             psError(PS_ERR_UNKNOWN, false, "database error");
             return false;
-        } 
+        }
 
         // sanity check: we should have inserted at least one row
@@ -675,5 +675,5 @@
             // init
             long counter = 0,   // the total number of elements zipped so far
-            i = 0,              // which array in the set 
+            i = 0,              // which array in the set
             index = 0;          // the depth into each array
             // test
@@ -782,10 +782,10 @@
     PXOPT_COPY_STR(config->args, where,  "-class_id", "class_id", "==");
 
-    PXOPT_LOOKUP_S16(code, config->args, "-code", true, false);
-
-    if (!pxSetFaultCode(config->dbh, "pzDownloadImfile", where, code)) {
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false);
+
+    if (!pxSetFaultCode(config->dbh, "pzDownloadImfile", where, fault)) {
         psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
-	psFree (where);
-	return false;
+        psFree (where);
+        return false;
     }
     psFree(where);
Index: trunk/ippTools/src/pztoolConfig.c
===================================================================
--- trunk/ippTools/src/pztoolConfig.c	(revision 23661)
+++ trunk/ippTools/src/pztoolConfig.c	(revision 23688)
@@ -45,8 +45,8 @@
     // -adddatastore
     psMetadata *adddatastoreArgs = psMetadataAlloc();
-    psMetadataAddStr(adddatastoreArgs, PS_LIST_TAIL, "-inst", 0,            "define camera ID", NULL); 
-    psMetadataAddStr(adddatastoreArgs, PS_LIST_TAIL, "-telescope", 0,            "define telescope ID", NULL); 
+    psMetadataAddStr(adddatastoreArgs, PS_LIST_TAIL, "-inst", 0,            "define camera ID", NULL);
+    psMetadataAddStr(adddatastoreArgs, PS_LIST_TAIL, "-telescope", 0,            "define telescope ID", NULL);
     psMetadataAddStr(adddatastoreArgs, PS_LIST_TAIL, "-uri", 0,            "define storage uri", NULL);
-    
+
     // -datastore
     psMetadata *datastoreArgs = psMetadataAlloc();
@@ -55,16 +55,16 @@
     // -seen
     psMetadata *seenArgs = psMetadataAlloc();
-    psMetadataAddStr(seenArgs, PS_LIST_TAIL, "-exp_name", 0,            "define exposure ID", NULL); 
-    psMetadataAddStr(seenArgs, PS_LIST_TAIL, "-inst", 0,            "define camera ID", NULL); 
-    psMetadataAddStr(seenArgs, PS_LIST_TAIL, "-telescope", 0,            "define telescope ID", NULL); 
-    psMetadataAddStr(seenArgs, PS_LIST_TAIL, "-exp_type", 0,            "define exposure type", NULL); 
+    psMetadataAddStr(seenArgs, PS_LIST_TAIL, "-exp_name", 0,            "define exposure ID", NULL);
+    psMetadataAddStr(seenArgs, PS_LIST_TAIL, "-inst", 0,            "define camera ID", NULL);
+    psMetadataAddStr(seenArgs, PS_LIST_TAIL, "-telescope", 0,            "define telescope ID", NULL);
+    psMetadataAddStr(seenArgs, PS_LIST_TAIL, "-exp_type", 0,            "define exposure type", NULL);
     psMetadataAddBool(seenArgs, PS_LIST_TAIL, "-simple", 0,            "use the simple output format", false);
-    
+
     // -pendingexp
     psMetadata *pendingexpArgs = psMetadataAlloc();
-    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-exp_name", 0,            "define exposure ID", NULL); 
-    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-inst", 0,            "define camera ID", NULL); 
-    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-telescope", 0,            "define telescope ID", NULL); 
-    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-exp_type", 0,            "define exposure type", NULL); 
+    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-exp_name", 0,            "define exposure ID", NULL);
+    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-inst", 0,            "define camera ID", NULL);
+    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-telescope", 0,            "define telescope ID", NULL);
+    psMetadataAddStr(pendingexpArgs, PS_LIST_TAIL, "-exp_type", 0,            "define exposure type", NULL);
     psMetadataAddBool(pendingexpArgs, PS_LIST_TAIL, "-desc", 0,            "sort ouput in descending format", false);
     psMetadataAddU64(pendingexpArgs, PS_LIST_TAIL, "-limit",  0,            "limit result set to N items", 0);
@@ -73,8 +73,8 @@
     // -pendingimfile
     psMetadata *pendingimfileArgs = psMetadataAlloc();
-    psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-exp_name", 0,            "define exposure ID", NULL); 
-    psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-inst", 0,            "define camera ID", NULL); 
-    psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-telescope", 0,            "define telescope ID", NULL); 
-    psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-exp_type", 0,            "define exposure type", NULL); 
+    psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-exp_name", 0,            "define exposure ID", NULL);
+    psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-inst", 0,            "define camera ID", NULL);
+    psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-telescope", 0,            "define telescope ID", NULL);
+    psMetadataAddStr(pendingimfileArgs, PS_LIST_TAIL, "-exp_type", 0,            "define exposure type", NULL);
     psMetadataAddBool(pendingimfileArgs, PS_LIST_TAIL, "-desc", 0,            "sort ouput in descending format", false);
     psMetadataAddU64(pendingimfileArgs, PS_LIST_TAIL, "-limit",  0,            "limit result set to N items", 0);
@@ -83,7 +83,7 @@
     // -copydone
     psMetadata *copydoneArgs = psMetadataAlloc();
-    psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-exp_name", 0,            "define exposure ID (required)", NULL); 
-    psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-inst", 0,            "define camera ID (required)", NULL); 
-    psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-telescope", 0,            "define telescope ID (required)", NULL); 
+    psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-exp_name", 0,            "define exposure ID (required)", NULL);
+    psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-inst", 0,            "define camera ID (required)", NULL);
+    psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-telescope", 0,            "define telescope ID (required)", NULL);
     psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-class", 0,            "define class", NULL);
     psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-class_id", 0,            "define class_id", NULL);
@@ -95,5 +95,5 @@
     psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-label",  0,        "define the label for the chip stage", NULL);
     psMetadataAddStr(copydoneArgs, PS_LIST_TAIL, "-hostname",  0,     "define the host that copied the image", NULL);
-    psMetadataAddS16(copydoneArgs, PS_LIST_TAIL, "-code",  0,            "set fault code", 0);
+    psMetadataAddS16(copydoneArgs, PS_LIST_TAIL, "-fault",  0,            "set fault code", 0);
     psMetadataAddBool(copydoneArgs, PS_LIST_TAIL, "-row_lock", 0,     "lock pzDownImfile rows while advancing an exposure", false);
     // XXX: remove this once advance is fixed
@@ -102,7 +102,7 @@
     // -copied
     psMetadata *copiedArgs = psMetadataAlloc();
-    psMetadataAddStr(copiedArgs, PS_LIST_TAIL, "-exp_name", 0,            "define exposure ID", NULL); 
-    psMetadataAddStr(copiedArgs, PS_LIST_TAIL, "-inst", 0,            "define camera ID", NULL); 
-    psMetadataAddStr(copiedArgs, PS_LIST_TAIL, "-telescope", 0,            "define telescope ID", NULL); 
+    psMetadataAddStr(copiedArgs, PS_LIST_TAIL, "-exp_name", 0,            "define exposure ID", NULL);
+    psMetadataAddStr(copiedArgs, PS_LIST_TAIL, "-inst", 0,            "define camera ID", NULL);
+    psMetadataAddStr(copiedArgs, PS_LIST_TAIL, "-telescope", 0,            "define telescope ID", NULL);
     psMetadataAddStr(copiedArgs, PS_LIST_TAIL, "-class", 0,            "define class", NULL);
     psMetadataAddStr(copiedArgs, PS_LIST_TAIL, "-class_id", 0,            "define class_id", NULL);
@@ -113,19 +113,19 @@
     // -updatecopied
     psMetadata *updatecopiedArgs = psMetadataAlloc();
-    psMetadataAddStr(updatecopiedArgs, PS_LIST_TAIL, "-exp_name", 0,            "define exposure ID (required)", NULL); 
-    psMetadataAddStr(updatecopiedArgs, PS_LIST_TAIL, "-inst", 0,            "define camera ID (required)", NULL); 
-    psMetadataAddStr(updatecopiedArgs, PS_LIST_TAIL, "-telescope", 0,            "define telescope ID (required)", NULL); 
+    psMetadataAddStr(updatecopiedArgs, PS_LIST_TAIL, "-exp_name", 0,            "define exposure ID (required)", NULL);
+    psMetadataAddStr(updatecopiedArgs, PS_LIST_TAIL, "-inst", 0,            "define camera ID (required)", NULL);
+    psMetadataAddStr(updatecopiedArgs, PS_LIST_TAIL, "-telescope", 0,            "define telescope ID (required)", NULL);
     psMetadataAddStr(updatecopiedArgs, PS_LIST_TAIL, "-class", 0,            "define class", NULL);
     psMetadataAddStr(updatecopiedArgs, PS_LIST_TAIL, "-class_id", 0,            "define class_id", NULL);
-    psMetadataAddS16(updatecopiedArgs, PS_LIST_TAIL, "-code",  0,            "search by fault code", 0);
+    psMetadataAddS16(updatecopiedArgs, PS_LIST_TAIL, "-fault",  0,            "search by fault code", 0);
 
     // -revertcopied
     psMetadata *revertcopiedArgs = psMetadataAlloc();
-    psMetadataAddStr(revertcopiedArgs, PS_LIST_TAIL, "-exp_name", 0,            "define exposure ID (required)", NULL); 
-    psMetadataAddStr(revertcopiedArgs, PS_LIST_TAIL, "-inst", 0,            "define camera ID (required)", NULL); 
-    psMetadataAddStr(revertcopiedArgs, PS_LIST_TAIL, "-telescope", 0,            "define telescope ID (required)", NULL); 
+    psMetadataAddStr(revertcopiedArgs, PS_LIST_TAIL, "-exp_name", 0,            "define exposure ID (required)", NULL);
+    psMetadataAddStr(revertcopiedArgs, PS_LIST_TAIL, "-inst", 0,            "define camera ID (required)", NULL);
+    psMetadataAddStr(revertcopiedArgs, PS_LIST_TAIL, "-telescope", 0,            "define telescope ID (required)", NULL);
     psMetadataAddStr(revertcopiedArgs, PS_LIST_TAIL, "-class", 0,            "define class", NULL);
     psMetadataAddStr(revertcopiedArgs, PS_LIST_TAIL, "-class_id", 0,            "define class_id", NULL);
-    psMetadataAddS16(revertcopiedArgs, PS_LIST_TAIL, "-code",  0,            "search by fault code", 0);
+    psMetadataAddS16(revertcopiedArgs, PS_LIST_TAIL, "-fault",  0,            "search by fault code", 0);
 
     // -clearcommonfaults
@@ -134,7 +134,7 @@
     // -toadvance
     psMetadata *toadvanceArgs = psMetadataAlloc();
-    psMetadataAddStr(toadvanceArgs, PS_LIST_TAIL, "-exp_name", 0,      "define exposure ID", NULL); 
-    psMetadataAddStr(toadvanceArgs, PS_LIST_TAIL, "-inst", 0,          "define camera ID", NULL); 
-    psMetadataAddStr(toadvanceArgs, PS_LIST_TAIL, "-telescope", 0,     "define telescope ID", NULL); 
+    psMetadataAddStr(toadvanceArgs, PS_LIST_TAIL, "-exp_name", 0,      "define exposure ID", NULL);
+    psMetadataAddStr(toadvanceArgs, PS_LIST_TAIL, "-inst", 0,          "define camera ID", NULL);
+    psMetadataAddStr(toadvanceArgs, PS_LIST_TAIL, "-telescope", 0,     "define telescope ID", NULL);
     psMetadataAddStr(toadvanceArgs, PS_LIST_TAIL, "-label",  0,        "define the label for the chip stage", NULL);
     psMetadataAddBool(toadvanceArgs, PS_LIST_TAIL, "-simple",  0,      "use the simple output format", false);
@@ -143,7 +143,7 @@
     // -advance
     psMetadata *advanceArgs = psMetadataAlloc();
-    psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-exp_name", 0,   "define exposure ID (required)", NULL); 
-    psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-inst", 0,       "define camera ID (required)", NULL); 
-    psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-telescope", 0,  "define telescope ID (required)", NULL); 
+    psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-exp_name", 0,   "define exposure ID (required)", NULL);
+    psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-inst", 0,       "define camera ID (required)", NULL);
+    psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-telescope", 0,  "define telescope ID (required)", NULL);
     psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-workdir",  0,   "define the \"default\" workdir for this exposure (required)", NULL);
     psMetadataAddStr(advanceArgs, PS_LIST_TAIL, "-dvodb",  0,     "define the dvodb for the next processing step", NULL);
Index: trunk/ippTools/src/regtool.c
===================================================================
--- trunk/ippTools/src/regtool.c	(revision 23661)
+++ trunk/ippTools/src/regtool.c	(revision 23688)
@@ -238,5 +238,7 @@
     PXOPT_LOOKUP_TIME(dateobs, config->args, "-dateobs", false, false);
     PXOPT_LOOKUP_STR(hostname, config->args, "-hostname", false, false);
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
+
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
+    PXOPT_LOOKUP_S16(quality, config->args, "-quality", false, false);
 
     if (!rawImfileInsert(
@@ -302,5 +304,6 @@
         ignored,
         hostname,
-        code,
+        fault,
+        quality,
         NULL,
         0
@@ -408,5 +411,5 @@
     PXOPT_COPY_STR(config->args, where,  "-tmp_class_id", "tmp_class_id", "==");
     PXOPT_COPY_STR(config->args, where,  "-class_id",     "class_id", "==");
-    PXOPT_COPY_S16(config->args, where,  "-code",         "fault", "==");
+    PXOPT_COPY_S16(config->args, where,  "-fault",         "fault", "==");
     PXOPT_COPY_S64(config->args, where,  "-exp_id_begin", "exp_id", ">=");
     PXOPT_COPY_S64(config->args, where,  "-exp_id_end", "exp_id", "<=");
@@ -452,13 +455,13 @@
     PXOPT_LOOKUP_STR(class_id, config->args, "-class_id", true, false);
 
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false);
     PXOPT_LOOKUP_F64(user_1, config->args, "-user_1", false, false);
 
-    if ((code == INT16_MAX) && !isfinite(user_1)) { 
-        psError(PS_ERR_UNKNOWN, false, "one of -code or -user_1 must be selected");
-        return false;
-    }
-    if ((code != INT16_MAX) && isfinite(user_1)) { 
-        psError(PS_ERR_UNKNOWN, false, "only one of -code or -user_1 must be selected");
+    if ((fault == INT16_MAX) && !isfinite(user_1)) { 
+        psError(PS_ERR_UNKNOWN, false, "one of -fault or -user_1 must be selected");
+        return false;
+    }
+    if ((fault != INT16_MAX) && isfinite(user_1)) { 
+        psError(PS_ERR_UNKNOWN, false, "only one of -fault or -user_1 must be selected");
         return false;
     }
@@ -468,7 +471,7 @@
     PXOPT_COPY_STR(config->args, where,  "-class_id",     "class_id", "==");
 
-    if (code != INT16_MAX) {
+    if (fault != INT16_MAX) {
 	// this is fairly dangerous : can set all if the where is not set...
-	if (!pxSetFaultCode(config->dbh, "rawImfile", where, code)) {
+	if (!pxSetFaultCode(config->dbh, "rawImfile", where, fault)) {
 	    psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
 	    psFree (where);
@@ -644,5 +647,5 @@
 
     // default
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
 
     psString query = pxDataGet("regtool_pendingexp.sql");
@@ -801,5 +804,5 @@
         moon_phase,
         hostname,
-        code,
+        fault,
         NULL,
         0
@@ -995,5 +998,5 @@
     psMetadata *where = psMetadataAlloc();
     PXOPT_COPY_S64(config->args, where,  "-exp_id",       "exp_id", "==");
-    PXOPT_COPY_S16(config->args, where,  "-code",         "fault", "==");
+    PXOPT_COPY_S16(config->args, where,  "-fault",         "fault", "==");
     PXOPT_COPY_S64(config->args, where,  "-exp_id_begin", "exp_id", ">=");
     PXOPT_COPY_S64(config->args, where,  "-exp_id_end", "exp_id", "<=");
@@ -1039,7 +1042,7 @@
     PXOPT_COPY_S64(config->args, where,  "-exp_id",       "exp_id", "==");
 
-    PXOPT_LOOKUP_S16(code, config->args, "-code", true, false);
-
-    if (!pxSetFaultCode(config->dbh, "rawExp", where, code)) {
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false);
+
+    if (!pxSetFaultCode(config->dbh, "rawExp", where, fault)) {
         psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
         psFree(where);
@@ -1161,5 +1164,5 @@
     char sqlFilename[80];
   } ExportTable;
-  
+
   int numExportTables = 2;
 
@@ -1241,5 +1244,5 @@
 
   PS_ASSERT_PTR_NON_NULL(config, NULL);
-  
+
   PXOPT_LOOKUP_STR(infile, config->args, "-infile", true,  false);
 
@@ -1252,5 +1255,5 @@
   psAssert (item, "entry not in input?");
   psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");
-  
+
   psMetadataItem *entry = psListGet (item->data.list, 0);
   assert (entry);
Index: trunk/ippTools/src/regtoolConfig.c
===================================================================
--- trunk/ippTools/src/regtoolConfig.c	(revision 23661)
+++ trunk/ippTools/src/regtoolConfig.c	(revision 23688)
@@ -122,5 +122,6 @@
     ADD_OPT(Time, addprocessedimfileArgs, "-dateobs",        "define observation time",         NULL);
     ADD_OPT(Str,  addprocessedimfileArgs, "-hostname",       "define host name",                NULL);
-    ADD_OPT(S16,  addprocessedimfileArgs, "-code",           "set fault code",                  0);
+    ADD_OPT(S16,  addprocessedimfileArgs, "-fault",           "set fault code",                  0);
+    ADD_OPT(S16,  addprocessedimfileArgs, "-quality",        "set quality flag", 0);
 
     // -processedimfile
@@ -140,5 +141,5 @@
     ADD_OPT(Str, revertprocessedimfileArgs, "-tmp_class_id",  "searcy by temp. class ID", NULL);
     ADD_OPT(Str, revertprocessedimfileArgs, "-class_id",      "search by class ID", NULL);
-    ADD_OPT(S16, revertprocessedimfileArgs, "-code",          "search by fault code", 0);
+    ADD_OPT(S16, revertprocessedimfileArgs, "-fault",          "search by fault code", 0);
     ADD_OPT(S64, revertprocessedimfileArgs, "-exp_id_begin",  "search by exposure ID", 0);
     ADD_OPT(S64, revertprocessedimfileArgs, "-exp_id_end",    "search by exposure ID", 0);
@@ -149,5 +150,5 @@
     ADD_OPT(Str, updateprocessedimfileArgs, "-class_id",      "search by class ID", NULL);
     ADD_OPT(F64, updateprocessedimfileArgs, "-user_1",        "set user stat (1)", NAN);
-    ADD_OPT(S16, updateprocessedimfileArgs, "-code",          "set fault code", INT16_MAX);
+    ADD_OPT(S16, updateprocessedimfileArgs, "-fault",          "set fault code (required)", INT16_MAX);
 
     // -pendingexp
@@ -226,5 +227,5 @@
     ADD_OPT(Str,  addprocessedexpArgs, "-label",            "define label for chip stage (non-detrend data only)", NULL);
     ADD_OPT(Str,  addprocessedexpArgs, "-hostname",         "define host name", NULL);
-    ADD_OPT(S16,  addprocessedexpArgs, "-code",             "set fault code", 0);
+    ADD_OPT(S16,  addprocessedexpArgs, "-fault",             "set fault code", 0);
 
     // -processedexp
@@ -276,5 +277,5 @@
     psMetadata *revertprocessedexpArgs = psMetadataAlloc();
     psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-exp_id",   0,            "search by exposure ID", 0);
-    psMetadataAddS16(revertprocessedexpArgs, PS_LIST_TAIL, "-code",     0,            "search by fault code", 0);
+    psMetadataAddS16(revertprocessedexpArgs, PS_LIST_TAIL, "-fault",     0,            "search by fault code", 0);
     psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-exp_id_begin",   0,      "search by exposure ID", 0);
     psMetadataAddS64(revertprocessedexpArgs, PS_LIST_TAIL, "-exp_id_end",   0,      "search by exposure ID", 0);
@@ -283,5 +284,5 @@
     psMetadata *updatedprocessedexpArgs = psMetadataAlloc();
     psMetadataAddS64(updatedprocessedexpArgs, PS_LIST_TAIL, "-exp_id",  0,            "search by exposure ID", 0);
-    psMetadataAddS16(updatedprocessedexpArgs, PS_LIST_TAIL, "-code",    0,            "set fault code (required)", INT16_MAX);
+    psMetadataAddS16(updatedprocessedexpArgs, PS_LIST_TAIL, "-fault",    0,            "set fault code (required)", INT16_MAX);
 
     // -exportrun
Index: trunk/ippTools/src/stacktool.c
===================================================================
--- trunk/ippTools/src/stacktool.c	(revision 23661)
+++ trunk/ippTools/src/stacktool.c	(revision 23688)
@@ -718,5 +718,6 @@
 
     // default values
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
+    PXOPT_LOOKUP_S16(quality, config->args, "-quality", false, false);
 
     if (!psDBTransaction(config->dbh)) {
@@ -754,5 +755,6 @@
                                hostname,
                                good_frac,
-                               code
+                               fault,
+                               quality
           )) {
         if (!psDBRollback(config->dbh)) {
@@ -862,5 +864,5 @@
     PXOPT_COPY_S64(config->args, where, "-stack_id", "stackSumSkyfile.stack_id", "==");
     PXOPT_COPY_STR(config->args, where, "-label", "stackRun.label", "==");
-    PXOPT_COPY_S16(config->args, where, "-code", "stackSumSkyfile.fault", "==");
+    PXOPT_COPY_S16(config->args, where, "-fault", "stackSumSkyfile.fault", "==");
 
     if (!psDBTransaction(config->dbh)) {
@@ -1169,10 +1171,10 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    PXOPT_LOOKUP_S16(code, config->args, "-code", true, false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", true, false);
 
     psMetadata *where = psMetadataAlloc();
     PXOPT_COPY_S64(config->args, where, "-stack_id",   "stack_id",   "==");
 
-    if (!pxSetFaultCode(config->dbh, "stackSumSkyfile", where, code)) {
+    if (!pxSetFaultCode(config->dbh, "stackSumSkyfile", where, fault)) {
         psError(PS_ERR_UNKNOWN, false, "failed to set set fault flag");
         psFree (where);
@@ -1192,5 +1194,5 @@
 
   int numExportTables = 3;
-  
+
   PS_ASSERT_PTR_NON_NULL(config, NULL);
 
@@ -1262,11 +1264,11 @@
 {
   unsigned int nFail;
-  
+
   int numImportTables = 2;
-  
+
   char tables[2] [80] = {"stackInputSkyfile", "stackSumSkyfile"};
 
   PS_ASSERT_PTR_NON_NULL(config, NULL);
-  
+
   PXOPT_LOOKUP_STR(infile, config->args, "-infile", true,  false);
 
@@ -1293,5 +1295,5 @@
     psAssert (item, "entry not in input?");
     psAssert (item->type == PS_DATA_METADATA_MULTI, "entry not multi?");
-  
+
     switch (i) {
       case 0:
@@ -1307,5 +1309,5 @@
         }
         break;
-        
+
       case 1:
         for (int i = 0; i < item->data.list->n; i++) {
@@ -1322,5 +1324,5 @@
     }
   }
-  
+
   return true;
 }
Index: trunk/ippTools/src/stacktoolConfig.c
===================================================================
--- trunk/ippTools/src/stacktoolConfig.c	(revision 23661)
+++ trunk/ippTools/src/stacktoolConfig.c	(revision 23688)
@@ -147,5 +147,6 @@
     psMetadataAddStr(addsumskyfileArgs, PS_LIST_TAIL, "-hostname", 0,            "define hostname", 0);
     psMetadataAddF32(addsumskyfileArgs, PS_LIST_TAIL, "-good_frac",  0,            "define %% of good pixels", NAN);
-    psMetadataAddS16(addsumskyfileArgs, PS_LIST_TAIL, "-code",  0,            "set fault code", 0);
+    psMetadataAddS16(addsumskyfileArgs, PS_LIST_TAIL, "-fault",  0,            "set fault code", 0);
+    psMetadataAddS16(addsumskyfileArgs, PS_LIST_TAIL, "-quality",  0,            "set quality", 0);
 
     // -sumskyfile
@@ -162,5 +163,5 @@
     psMetadataAddS64(revertsumskyfileArgs, PS_LIST_TAIL, "-stack_id", 0,            "search by stack ID", 0);
     psMetadataAddStr(revertsumskyfileArgs, PS_LIST_TAIL, "-label", 0, "search by label", 0);
-    psMetadataAddS16(revertsumskyfileArgs, PS_LIST_TAIL, "-code",  0,            "search by fault code", 0);
+    psMetadataAddS16(revertsumskyfileArgs, PS_LIST_TAIL, "-fault",  0,            "search by fault code", 0);
 
     // -pendingcleanuprun
@@ -185,5 +186,5 @@
     psMetadata *updatesumskyfileArgs = psMetadataAlloc();
     psMetadataAddS64(updatesumskyfileArgs, PS_LIST_TAIL, "-stack_id", 0,            "define stack ID (required)", 0);
-    psMetadataAddS16(updatesumskyfileArgs, PS_LIST_TAIL, "-code", 0,            "set fault code (required)", 0);
+    psMetadataAddS16(updatesumskyfileArgs, PS_LIST_TAIL, "-fault", 0,            "set fault code (required)", 0);
 
     // -exportrun
Index: trunk/ippTools/src/warptool.c
===================================================================
--- trunk/ippTools/src/warptool.c	(revision 23661)
+++ trunk/ippTools/src/warptool.c	(revision 23688)
@@ -609,5 +609,5 @@
     PXOPT_LOOKUP_STR(mapfile, config->args, "-mapfile", false, false);
     PXOPT_LOOKUP_S64(warp_id, config->args, "-warp_id", false, false);
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
 
     if (!psDBTransaction(config->dbh)) {
@@ -616,5 +616,5 @@
     }
 
-    if (code == 0) {
+    if (fault == 0) {
         if (!parseAndInsertSkyCellMap(config, mapfile)) {
             psError(PS_ERR_UNKNOWN, false, "failed to inject mapfile: %s into the database", mapfile);
@@ -631,5 +631,5 @@
             NULL,   // tess_id
             NULL,   // class_id
-            code    // fault
+            fault    // fault
         );
     }
@@ -896,9 +896,9 @@
     PXOPT_LOOKUP_STR(hostname, config->args, "-hostname", false, false);
     PXOPT_LOOKUP_F32(good_frac, config->args, "-good_frac", false, false);
-    PXOPT_LOOKUP_BOOL(accept, config->args, "-accept", false);
     PXOPT_LOOKUP_BOOL(magicked, config->args, "-magicked", false);
 
     // default values
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
+    PXOPT_LOOKUP_S16(quality, config->args, "-quality", false, false);
 
     // we don't want to insert the last skyfile in a run but then not mark the
@@ -927,6 +927,6 @@
                            ymin,
                            ymax,
-                           !accept,
-                           code,
+                           fault,
+                           quality,
                            magicked
         )) {
@@ -1112,5 +1112,5 @@
     PXOPT_COPY_STR(config->args, where, "-reduction",  "rawExp.reduction", "==");
     PXOPT_COPY_STR(config->args, where, "-label",      "warpRun.label", "==");
-    PXOPT_COPY_S16(config->args, where, "-code",       "warpSkyfile.fault", "==");
+    PXOPT_COPY_S16(config->args, where, "-fault",       "warpSkyfile.fault", "==");
 
     if (!psListLength(where->list)
@@ -1560,12 +1560,12 @@
     PS_ASSERT_PTR_NON_NULL(config, false);
 
-    // warp_id, skycell_id, code are required
+    // warp_id, skycell_id, fault are required
     PXOPT_LOOKUP_S64(warp_id, config->args, "-warp_id", true, false);
     PXOPT_LOOKUP_STR(skycell_id, config->args, "-skycell_id", true, false);
-    PXOPT_LOOKUP_S16(code, config->args, "-code", false, false);
+    PXOPT_LOOKUP_S16(fault, config->args, "-fault", false, false);
 
     psString query = pxDataGet("warptool_updateskyfile.sql");
 
-    if (!p_psDBRunQueryF(config->dbh, query, code, warp_id, skycell_id)) {
+    if (!p_psDBRunQueryF(config->dbh, query, fault, warp_id, skycell_id)) {
         psError(PS_ERR_UNKNOWN, false, "database error");
         return false;
Index: trunk/ippTools/src/warptoolConfig.c
===================================================================
--- trunk/ippTools/src/warptoolConfig.c	(revision 23661)
+++ trunk/ippTools/src/warptoolConfig.c	(revision 23688)
@@ -155,5 +155,5 @@
     psMetadataAddStr(addoverlapArgs, PS_LIST_TAIL, "-mapfile", 0,            "path to skycell <-> imfile mapping file", NULL);
     psMetadataAddS64(addoverlapArgs, PS_LIST_TAIL, "-warp_id",  0,            "set warp ID", 0);
-    psMetadataAddS16(addoverlapArgs, PS_LIST_TAIL, "-code",  0,            "set fault code", 0);
+    psMetadataAddS16(addoverlapArgs, PS_LIST_TAIL, "-fault",  0,            "set fault code", 0);
 
     // -scmap
@@ -190,7 +190,7 @@
     psMetadataAddStr(addwarpedArgs, PS_LIST_TAIL, "-hostname", 0,            "define hostname", 0);
     psMetadataAddF32(addwarpedArgs, PS_LIST_TAIL, "-good_frac",  0,            "define %% of good pixels", NAN);
-    psMetadataAddBool(addwarpedArgs, PS_LIST_TAIL, "-accept",  0, "define if this skycell should be accepted", false);
     psMetadataAddBool(addwarpedArgs, PS_LIST_TAIL, "-magicked",  0, "define if this skycell has been magicked", false);
-    psMetadataAddS16(addwarpedArgs, PS_LIST_TAIL, "-code",  0,            "set fault code", 0);
+    psMetadataAddS16(addwarpedArgs, PS_LIST_TAIL, "-fault",  0,            "set fault code", 0);
+    psMetadataAddS16(addwarpedArgs, PS_LIST_TAIL, "-quality",  0,            "set quality", 0);
 
     // -warped
@@ -216,5 +216,5 @@
     psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-reduction",  0,            "search by warpRun reduction class", NULL);
     psMetadataAddStr(revertwarpedArgs, PS_LIST_TAIL, "-label",  0,            "search by warpRun label", NULL);
-    psMetadataAddS16(revertwarpedArgs, PS_LIST_TAIL, "-code",  0,            "search by fault code", 0);
+    psMetadataAddS16(revertwarpedArgs, PS_LIST_TAIL, "-fault",  0,            "search by fault code", 0);
     psMetadataAddBool(revertwarpedArgs, PS_LIST_TAIL, "-all",  0,            "allow everything to be queued without search terms", false);
 
@@ -269,5 +269,5 @@
     psMetadataAddS64(updateskyfileArgs, PS_LIST_TAIL, "-warp_id", 0,    "warptool ID to update", 0);
     psMetadataAddStr(updateskyfileArgs, PS_LIST_TAIL, "-skycell_id", 0, "skycell ID to update", NULL);
-    psMetadataAddS16(updateskyfileArgs, PS_LIST_TAIL, "-code",  0,      "new fault code", 0);
+    psMetadataAddS16(updateskyfileArgs, PS_LIST_TAIL, "-fault",  0,      "new fault code", 0);
 
     // -exportrun
