Index: /branches/eam_branches/ipp-20140206/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c	(revision 36530)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c	(revision 36531)
@@ -167,14 +167,22 @@
   off_t i, oldID, newID;
 
+  if (!IDmap->old) {
+    fprintf (stderr, "input database has image IDs, but no Image table\n");
+    return FALSE;
+  }
+
+  off_t lastID = IDmap->old[IDmap->Nmap-1];
+
   for (i = 0; i < catalog[0].Nmeasure; i++) {
     oldID = catalog[0].measure[i].imageID;
     if (oldID == 0) continue;
 
-    if (!IDmap->old) {
-      fprintf (stderr, "input database has image IDs, but no Image table\n");
-    }
-
     newID = dvo_map_image_ID (IDmap, oldID);
     if (newID == 0) {
+      if (oldID > lastID) {
+	fprintf (stderr, "problem with image IDs : input out of range\n");
+	fprintf (stderr, "old ID: "OFF_T_FMT", last ID: "OFF_T_FMT"\n", oldID, lastID);
+	exit (2);
+      }
       if (!IDmap->notFound[oldID]) {
 	fprintf (stderr, "cannot find image ID "OFF_T_FMT"\n",  oldID);
Index: /branches/eam_branches/ipp-20140206/Ohana/src/dvomerge/src/dvomergeUpdate.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/dvomerge/src/dvomergeUpdate.c	(revision 36530)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/dvomerge/src/dvomergeUpdate.c	(revision 36531)
@@ -111,5 +111,5 @@
   SetPhotcodeTable(NULL);
 
-  dvomergeUpdate_catalogs (input, output, outsky, inlist, NsecfiltInput, NsecfiltOutput, &IDmap, secfiltMap);
+  int status = dvomergeUpdate_catalogs (input, output, outsky, inlist, NsecfiltInput, NsecfiltOutput, &IDmap, secfiltMap);
 
   // save the output sky table copy
@@ -123,6 +123,11 @@
   gettimeofday (&stop, NULL);
   dtime = DTIME (stop, start);
+
+  if (!status) {
+    fprintf (stderr, "ERROR: elapsed time %9.4f sec\n", dtime);
+    exit (3);
+  }
+
   fprintf (stderr, "SUCCESS: elapsed time %9.4f sec\n", dtime);
-
   exit (0);
 }
Index: /branches/eam_branches/ipp-20140206/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c
===================================================================
--- /branches/eam_branches/ipp-20140206/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c	(revision 36530)
+++ /branches/eam_branches/ipp-20140206/Ohana/src/dvomerge/src/dvomergeUpdate_catalogs.c	(revision 36531)
@@ -140,4 +140,6 @@
     }
 
+    dvo_update_image_IDs (IDmap, &incatalog);
+
     // merge input into the appropriate output tables
     for (j = 0; j < outlist[0].Nregions; j++) {
@@ -156,10 +158,9 @@
       LoadCatalog (&outcatalog, outlist[0].regions[j], outcatalog.filename, "w", NsecfiltOutput);
 
-      dvo_update_image_IDs (IDmap, &incatalog);
       merge_catalogs_old (outlist[0].regions[j], &outcatalog, &incatalog, RADIUS, secfiltMap);
 
       outcatalog.catflags = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
 
-      if (outstat[i].missed) {
+      if (outstat[j].missed) {
 	dmhObjectAdd (outstat[j].history, &outcatalog.header, inStats);
       }
@@ -280,5 +281,9 @@
   }
   if (!PARALLEL_MANUAL && !PARALLEL_SERIAL) {
-    HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE);
+    int status = HostTableWaitJobsGetIO (table, __FILE__, __LINE__, VERBOSE);
+    if (!status) {
+      fprintf (stderr, "error running one of the remote clients\n");
+      return status;
+    }
   }
 
