Index: /branches/eam_branches/ipp-20101205/Ohana/src/libdvo/src/dvo_util.c
===================================================================
--- /branches/eam_branches/ipp-20101205/Ohana/src/libdvo/src/dvo_util.c	(revision 30447)
+++ /branches/eam_branches/ipp-20101205/Ohana/src/libdvo/src/dvo_util.c	(revision 30448)
@@ -255,4 +255,5 @@
       dvo_catalog_free (&catalog);
   }
+  size_t NInvalidDetID = 0;
   if (Ndetect) {
       dvoDetection *sorted;
@@ -262,5 +263,9 @@
       off_t i;
       for (i = 0; i < Ndetect; i++) {
-           sorted[detections[i].meas.detID] = detections[i];
+
+          if (detections[i].meas.detID < 0 || detections[i].meas.detID > (*pMaxDetID + 1))
+              NInvalidDetID++;
+          else
+              sorted[detections[i].meas.detID] = detections[i];
       }
       *results = sorted;
@@ -271,4 +276,6 @@
   FREE(detections);
 
+  if (NInvalidDetID) fprintf (stderr, "ERROR: Encountered %ld invalid detection IDs\n", NInvalidDetID);
+
   return (Ndetect);
 
Index: /branches/eam_branches/ipp-20101205/Ohana/src/tools/src/roc.c
===================================================================
--- /branches/eam_branches/ipp-20101205/Ohana/src/tools/src/roc.c	(revision 30447)
+++ /branches/eam_branches/ipp-20101205/Ohana/src/tools/src/roc.c	(revision 30448)
@@ -33,10 +33,11 @@
 
   usage();
-  exit (1);
+  exit (2);
 }
 
 int roc_create (int argc, char **argv) {
 
-  int i, j, n, Ninput, result, Nblocks, header_size, size_off, Noff, Nbytes, Nread;
+  int i, j, n, Ninput, result, Nblocks, header_size, size_off;
+  int status, Noff, Nbytes, Nread, Nwrite;
   off_t maxSize, *sizes, *bytes_read;
   char value;
@@ -124,5 +125,6 @@
   myAssert (target, "failed to open output");
 
-  fwrite (header, 1, header_size, target);
+  Nwrite = fwrite (header, 1, header_size, target);
+  myAssert (Nwrite == header_size, "failed to write header");
 
   ALLOCATE (inputData, char *, Ninput);
@@ -137,4 +139,5 @@
       Nbytes = fread (inputData[i], 1, Nread, input[i]);
       myAssert (Nbytes == Nread, "failed to read data");
+
       if (Nread < ROC_BLOCKSIZE) {
 	// if we have reached the end of the file, fill in the rest with NULLs
@@ -152,6 +155,10 @@
     }
 
-    fwrite (outputData, 1, ROC_BLOCKSIZE, target);
-  }
+    Nwrite = fwrite (outputData, 1, ROC_BLOCKSIZE, target);
+    myAssert (Nwrite == ROC_BLOCKSIZE, "failed to write data block");
+  }
+
+  status = fclose (target);
+  myAssert (!status, "failed to close rocfile");
 
   exit (0);
@@ -160,5 +167,6 @@
 int roc_repair (int argc, char **argv) {
 
-  int i, j, n, Ninput, Nblocks, header_size, Nbytes, Nread, Nfile, Nwrite;
+  int i, j, n, Ninput, Nblocks, header_size, Nbytes;
+  int status, Nread, Nfile, Nwrite;
   off_t *sizes, *bytes_read;
   char value;
@@ -204,5 +212,6 @@
   // read the full header
   fseeko (target, 0, SEEK_SET);
-  fread (header, 1, header_size, target);
+  Nread = fread (header, 1, header_size, target);
+  myAssert (Nread == header_size, "failed to read header");
 
   ptr = header;
@@ -255,4 +264,5 @@
       Nbytes = fread (inputData[i], 1, Nread, input[i]);
       myAssert (Nbytes == Nread, "failed to read data");
+
       if (Nread < ROC_BLOCKSIZE) {
 	// if we have reached the end of the file, fill in the rest with NULLs
@@ -261,5 +271,6 @@
       bytes_read[i] += Nread;
     }
-    fread (targetData, 1, ROC_BLOCKSIZE, target);
+    Nread = fread (targetData, 1, ROC_BLOCKSIZE, target);
+    myAssert (Nread == ROC_BLOCKSIZE, "failed to read from target");
     
     for (j = 0; j < ROC_BLOCKSIZE; j++) {
@@ -281,8 +292,12 @@
   for (i = 0; i < Ninput; i++) {
     if (i == Nfile) continue;
-    fclose(input[i]);
-  }
-  fclose (output);
-  fclose (target);
+    status = fclose(input[i]);
+    myAssert (!status, "failed to close input");
+  }
+  status = fclose (output);
+  myAssert (!status, "failed to close output file");
+
+  status = fclose (target);
+  myAssert (!status, "failed to close rocfile");
 
   exit (0);
Index: /branches/eam_branches/ipp-20101205/dbconfig/changes.txt
===================================================================
--- /branches/eam_branches/ipp-20101205/dbconfig/changes.txt	(revision 30447)
+++ /branches/eam_branches/ipp-20101205/dbconfig/changes.txt	(revision 30448)
@@ -1996,2 +1996,4 @@
 
 ALTER TABLE rawImfile ADD column video_cells TINYINT AFTER burntool_state;
+
+ALTER TABLE pstampDataStore ADD COLUMN need_magic INT;
Index: /branches/eam_branches/ipp-20101205/dbconfig/pstamp.md
===================================================================
--- /branches/eam_branches/ipp-20101205/dbconfig/pstamp.md	(revision 30447)
+++ /branches/eam_branches/ipp-20101205/dbconfig/pstamp.md	(revision 30448)
@@ -8,4 +8,5 @@
     uri         STR         255
     pollInterval S32        0
+    need_magic  S32         0
 END
 
Index: /branches/eam_branches/ipp-20101205/ippconfig/isp/camera.config
===================================================================
--- /branches/eam_branches/ipp-20101205/ippconfig/isp/camera.config	(revision 30447)
+++ /branches/eam_branches/ipp-20101205/ippconfig/isp/camera.config	(revision 30448)
@@ -78,2 +78,3 @@
 # don't censor any masked pixels when making postage stamps
 MASK.NO.CENSOR               U32 4294967295
+BURNTOOL.STATE.GOOD          S16  0  # Value for burntool_state with the most recent bt version.
Index: /branches/eam_branches/ipp-20101205/ippconfig/recipes/nightly_science.config
===================================================================
--- /branches/eam_branches/ipp-20101205/ippconfig/recipes/nightly_science.config	(revision 30447)
+++ /branches/eam_branches/ipp-20101205/ippconfig/recipes/nightly_science.config	(revision 30448)
@@ -25,4 +25,15 @@
   RETENTION_TIME S16 1
 END
+CLEAN_MODES METADATA
+  MODE           STR BGCHIP
+  COMMAND	 STR bgtool -dbname @DBNAME@ -updatechip -set_state goto_cleaned -state full -set_label goto_cleaned -label @LABEL@ -data_group @DATA_GROUP@
+  RETENTION_TIME S16 14
+END
+CLEAN_MODES METADATA
+  MODE           STR BGWARP
+  COMMAND	 STR bgtool -dbname @DBNAME@ -updatewarp -set_state goto_cleaned -state full -set_label goto_cleaned -label @LABEL@ -data_group @DATA_GROUP@
+  RETENTION_TIME S16 14
+END
+
 
 END_OF_NIGHT MULTI
@@ -93,5 +104,5 @@
   NAME      STR MD03
   DISTRIBUTION STR MD03
-  TESS      STR MD03
+  TESS      STR MD03.V2
   OBSMODE   STR MD
   OBJECT    STR MD03%
@@ -115,5 +126,5 @@
   NAME      STR MD05
   DISTRIBUTION STR MD05
-  TESS      STR MD05
+  TESS      STR MD05.V2
   OBSMODE   STR MD
   OBJECT    STR MD05%
@@ -212,4 +223,12 @@
   TESS         STR RINGS.V0
   OBSMODE      STR OSS
+  STACKABLE   BOOL FALSE
+  DIFFABLE    BOOL TRUE
+END
+TARGETS METADATA
+  NAME         STR PI
+  DISTRIBUTION STR SweetSpot
+  TESS         STR RINGS.V0
+  OBSMODE      STR PI
   STACKABLE   BOOL FALSE
   DIFFABLE    BOOL TRUE
Index: /branches/eam_branches/ipp-20101205/ppStack/src/ppStackConvolve.c
===================================================================
--- /branches/eam_branches/ipp-20101205/ppStack/src/ppStackConvolve.c	(revision 30447)
+++ /branches/eam_branches/ipp-20101205/ppStack/src/ppStackConvolve.c	(revision 30448)
@@ -113,4 +113,11 @@
                 options->inputMask->data.PS_TYPE_VECTOR_MASK_DATA[i] |= PPSTACK_MASK_MATCH;
                 psErrorClear();
+                if (!ppStackFilesIterateUp(config)) {
+                    psFree(rng);
+                    psFree(fpaList);
+                    psFree(cellList);
+                    psFree(target);
+                    return false;
+                }
                 continue;
             }
