Index: branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c
===================================================================
--- branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c	(revision 33737)
+++ branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/dvo_image_merge_dbs.c	(revision 33738)
@@ -116,4 +116,12 @@
   int status;
  
+  IDmap->old = NULL;
+  IDmap->new = NULL;
+
+  // it is OK if there are no images in the database, but there should be no imageIDs to map...
+  if (in->dbstate == LCK_EMPTY) {
+    return TRUE;
+  }
+
   images = gfits_table_get_Image (&in[0].ftable, &Nimages, &in[0].swapped);
   if (!images) {
@@ -199,4 +207,8 @@
     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) {
Index: branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/dvomergeCreate.c
===================================================================
--- branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/dvomergeCreate.c	(revision 33737)
+++ branches/eam_branches/ipp-20120405/Ohana/src/dvomerge/src/dvomergeCreate.c	(revision 33738)
@@ -124,16 +124,18 @@
   depth2 = insky2[0].regions[Ns].depth;
 
+  SkyList *outlist = SkyListByPatch (outsky, -1, &UserPatch);
+
   // loop over the populatable output regions
-  for (i = 0; i < outsky[0].Nregions; i++) {
-    if (!outsky[0].regions[i].table) continue;
-    if (VERBOSE) fprintf (stderr, "output: %s\n", outsky[0].regions[i].name);
+  for (i = 0; i < outlist[0].Nregions; i++) {
+    if (!outlist[0].regions[i][0].table) continue;
+    if (VERBOSE) fprintf (stderr, "output: %s\n", outlist[0].regions[i][0].name);
 
     // load / create output catalog
-    LoadCatalog (&outcatalog, &outsky[0].regions[i], outsky[0].filename[i], "w", NsecfiltOutput);
+    LoadCatalog (&outcatalog, outlist[0].regions[i], outlist[0].filename[i], "w", NsecfiltOutput);
 
     // combine only tables at equal or larger depth
       
     // load in all of the tables from input1 for this region
-    inlist = SkyListByBounds (insky1, depth1, outsky[0].regions[i].Rmin, outsky[0].regions[i].Rmax, outsky[0].regions[i].Dmin, outsky[0].regions[i].Dmax);
+    inlist = SkyListByBounds (insky1, depth1, outlist[0].regions[i][0].Rmin + 0.01, outlist[0].regions[i][0].Rmax - 0.01, outlist[0].regions[i][0].Dmin + 0.01, outlist[0].regions[i][0].Dmax - 0.01);
     for (j = 0; j < inlist[0].Nregions; j++) {
       if (VERBOSE) fprintf (stderr, "input 1: %s\n", inlist[0].regions[j][0].name);
@@ -149,5 +151,5 @@
       }
       dvo_update_image_IDs (&IDmap1, &incatalog);
-      merge_catalogs_new (&outsky[0].regions[i], &outcatalog, &incatalog, secfiltMap1);
+      merge_catalogs_new (outlist[0].regions[i], &outcatalog, &incatalog, secfiltMap1);
       dvo_catalog_unlock (&incatalog);
       dvo_catalog_free (&incatalog);
@@ -156,5 +158,5 @@
 
     // load in all of the tables from input2 for this region
-    inlist = SkyListByBounds (insky2, depth2, outsky[0].regions[i].Rmin, outsky[0].regions[i].Rmax, outsky[0].regions[i].Dmin, outsky[0].regions[i].Dmax);
+    inlist = SkyListByBounds (insky2, depth2, outlist[0].regions[i][0].Rmin + 0.01, outlist[0].regions[i][0].Rmax - 0.01, outlist[0].regions[i][0].Dmin + 0.01, outlist[0].regions[i][0].Dmax - 0.01);
     for (j = 0; j < inlist[0].Nregions; j++) {
       if (VERBOSE) fprintf (stderr, "input 2: %s\n", inlist[0].regions[j][0].name);
@@ -170,5 +172,5 @@
       }
       dvo_update_image_IDs (&IDmap2, &incatalog);
-      merge_catalogs_old (&outsky[0].regions[i], &outcatalog, &incatalog, RADIUS, secfiltMap2);
+      merge_catalogs_old (outlist[0].regions[i], &outcatalog, &incatalog, RADIUS, secfiltMap2);
       dvo_catalog_unlock (&incatalog);
       dvo_catalog_free (&incatalog);
@@ -219,19 +221,18 @@
     in1DB.mode   = dvo_catalog_catmode (CATMODE);
     in1DB.format = dvo_catalog_catformat (CATFORMAT);
-    status       = dvo_image_lock (&in1DB, ImageCat, 3600.0, LCK_XCLD);  // shorter timeout?
+    status       = dvo_image_lock (&in1DB, ImageCat, 3600.0, LCK_SOFT);  // shorter timeout?
     if (!status) Shutdown ("ERROR: failure to lock image catalog %s", in1DB.filename);
 
     // load the image table 
-    if (in1DB.dbstate == LCK_EMPTY) {
-      Shutdown ("can't find input (1) image catalog %s", in1DB.filename);
-    }
-    if (!dvo_image_load (&in1DB, VERBOSE, TRUE)) {
-      Shutdown ("can't read input (1) image catalog %s", in1DB.filename);
-    }
-
+    if (in1DB.dbstate != LCK_EMPTY) {
+      if (!dvo_image_load (&in1DB, VERBOSE, TRUE)) {
+	Shutdown ("can't read input (1) image catalog %s", in1DB.filename);
+      }
+    }
+      
     // convert database table to internal structure & add to output image db
+    // if in1DB has no images, we will (later) insist that there are no image IDs to map
     dvo_image_merge_dbs(IDmap1, &outDB, &in1DB);
     dvo_image_unlock (&in1DB); // unlock input1
-
 
     /*** load input2/Images.dat ***/
@@ -239,16 +240,16 @@
     in2DB.mode   = dvo_catalog_catmode (CATMODE);
     in2DB.format = dvo_catalog_catformat (CATFORMAT);
-    status       = dvo_image_lock (&in2DB, ImageCat, 3600.0, LCK_XCLD);  // shorter timeout?
+    status       = dvo_image_lock (&in2DB, ImageCat, 3600.0, LCK_SOFT);  // shorter timeout?
     if (!status) Shutdown ("ERROR: failure to lock image catalog %s", in2DB.filename);
 
     /* load the image table */
-    if (in2DB.dbstate == LCK_EMPTY) {
-      Shutdown ("can't find input (2) image catalog %s", in2DB.filename);
-    }
-    if (!dvo_image_load (&in2DB, VERBOSE, TRUE)) {
-      Shutdown ("can't read input (2) image catalog %s", in2DB.filename);
+    if (in2DB.dbstate != LCK_EMPTY) {
+      if (!dvo_image_load (&in2DB, VERBOSE, TRUE)) {
+	Shutdown ("can't read input (2) image catalog %s", in2DB.filename);
+      }
     }
 
     // convert database table to internal structure & add to output image db
+    // if in1DB has no images, we will (later) insist that there are no image IDs to map
     dvo_image_merge_dbs(IDmap2, &outDB, &in2DB);
     dvo_image_unlock (&in2DB); // unlock input2
