Index: /branches/eam_branches/ipp-20150419/Ohana/src/relphot/include/relphot.h
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/relphot/include/relphot.h	(revision 38444)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/relphot/include/relphot.h	(revision 38445)
@@ -237,5 +237,5 @@
 char        *BOUNDARY_TREE;
 
-int SET_MREL_VERSION;
+// XXX deprecate int SET_MREL_VERSION;
 int IS_DIFF_DB;
 
@@ -525,5 +525,4 @@
 
 int launch_region_hosts (RegionHostTable *regionHosts);
-int strextend (char *input, char *format,...);
 
 Image *ImageTableLoad(char *filename, off_t *nimage);
Index: /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/ImageTable.c
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/ImageTable.c	(revision 38444)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/ImageTable.c	(revision 38445)
@@ -7,4 +7,5 @@
   FITS_DB db;
 
+  gfits_db_init (&db);
   db.mode   = dvo_catalog_catmode (CATMODE);
   db.format = dvo_catalog_catformat (CATFORMAT);
@@ -27,5 +28,5 @@
   // convert database table to internal structure (binary to Image)
   // 'image' points to the same memory as db->ftable->buffer
-  Image *image = gfits_table_get_Image (&db.ftable, &Nimage, &db.swapped);
+  Image *image = gfits_table_get_Image (&db.ftable, &Nimage, &db.scaledValue, &db.nativeOrder);
   if (!image) {
     Shutdown ("ERROR: failed to read images");
@@ -45,6 +46,8 @@
 
   // setup image table format and lock 
+  gfits_db_init (&db);
   db.mode   = dvo_catalog_catmode (CATMODE);
   db.format = dvo_catalog_catformat (CATFORMAT);
+
   status    = dvo_image_lock (&db, filename, 60.0, LCK_XCLD);  // shorter timeout?
   if (!status) Shutdown ("ERROR: failure to lock image catalog %s", db.filename);
Index: /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/args.c
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/args.c	(revision 38444)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/args.c	(revision 38445)
@@ -76,11 +76,4 @@
   }
 
-  SET_MREL_VERSION = 1;
-  if ((N = get_argument (argc, argv, "-set-mrel-version"))) {
-    remove_argument (N, &argc, argv);
-    SET_MREL_VERSION = atof(argv[N]);
-    remove_argument (N, &argc, argv);
-  }
-
   VERBOSE = VERBOSE2 = FALSE;
   if ((N = get_argument (argc, argv, "-v"))) {
@@ -547,11 +540,4 @@
   }
 
-  SET_MREL_VERSION = 1;
-  if ((N = get_argument (argc, argv, "-set-mrel-version"))) {
-    remove_argument (N, &argc, argv);
-    SET_MREL_VERSION = atof(argv[N]);
-    remove_argument (N, &argc, argv);
-  }
-
   VERBOSE = VERBOSE2 = FALSE;
   if ((N = get_argument (argc, argv, "-v"))) {
Index: /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/assign_images.c
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/assign_images.c	(revision 38444)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/assign_images.c	(revision 38445)
@@ -11,5 +11,5 @@
   // convert database table to internal structure (binary to Image)
   // 'image' points to the same memory as db->ftable->buffer
-  Image *image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped);
+  Image *image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].scaledValue, &db[0].nativeOrder);
   if (!image) {
       fprintf (stderr, "ERROR: failed to read images\n");
Index: /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/bcatalog.c
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/bcatalog.c	(revision 38444)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/bcatalog.c	(revision 38445)
@@ -224,5 +224,5 @@
   subcatalog[0].Nmeasure = Nmeasure;
   subcatalog[0].Nsecfilt = catalog[0].Nsecfilt;
-  subcatalog[0].Nsecf_mem = Naverage * catalog[0].Nsecfilt;
+  subcatalog[0].Nsecfilt_mem = Naverage * catalog[0].Nsecfilt;
 
   if (VERBOSE) {
@@ -347,5 +347,5 @@
   subcatalog[0].Nmeasure = Nmeasure;
   subcatalog[0].Nsecfilt = oldcatalog[0].Nsecfilt;
-  subcatalog[0].Nsecf_mem = Naverage * oldcatalog[0].Nsecfilt;
+  subcatalog[0].Nsecfilt_mem = Naverage * oldcatalog[0].Nsecfilt;
 
   return (TRUE);
@@ -440,5 +440,5 @@
   subcatalog[0].Nmeasure = Nmeasure;
   subcatalog[0].Nsecfilt = catalog[0].Nsecfilt;
-  subcatalog[0].Nsecf_mem = Naverage * catalog[0].Nsecfilt;
+  subcatalog[0].Nsecfilt_mem = Naverage * catalog[0].Nsecfilt;
 
   return (TRUE);
Index: /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/launch_region_hosts.c
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/launch_region_hosts.c	(revision 38444)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/launch_region_hosts.c	(revision 38445)
@@ -1,17 +1,4 @@
 # include "relphot.h"
 # define DEBUG 0
-
-int strextend (char *input, char *format,...) {
-
-  char tmpextra[1024], tmpline[1024];
-  va_list argp;
-
-  va_start (argp, format);
-  vsnprintf (tmpextra, 1024, format, argp);
-  snprintf (tmpline, 1024, "%s %s", input, tmpextra);
-  strcpy (input, tmpline);
-
-  return TRUE;
-}
 
 int launch_region_hosts (RegionHostTable *regionHosts) {
@@ -54,37 +41,37 @@
     ImageTableSave (filename, host->image, host->Nimage);
 
-    char command[1024];
-    snprintf (command, 1024, "relphot %s", PhotcodeList);
-    strextend (command, "-parallel-images %s", filename);
-    strextend (command, "-region-hosts %s", REGION_FILE);
-    strextend (command, "-region-hostID %d", host->hostID);
-    strextend (command, "-D CATDIR %s", CATDIR);
-    strextend (command, "-region %f %f %f %f", host->RminCat, host->RmaxCat, host->DminCat, host->DmaxCat);
-    strextend (command, "-statmode %s", STATMODE);
-    strextend (command, "-D CAMERA %s", CAMERA);
-    strextend (command, "-D STAR_TOOFEW %d", STAR_TOOFEW);
-    strextend (command, "-minerror %f", MIN_ERROR);
-    strextend (command, "-cloud-limit %f", CLOUD_TOLERANCE);
+    char *command = NULL;
+    strextend (&command, "relphot %s", PhotcodeList);
+    strextend (&command, "-parallel-images %s", filename);
+    strextend (&command, "-region-hosts %s", REGION_FILE);
+    strextend (&command, "-region-hostID %d", host->hostID);
+    strextend (&command, "-D CATDIR %s", CATDIR);
+    strextend (&command, "-region %f %f %f %f", host->RminCat, host->RmaxCat, host->DminCat, host->DmaxCat);
+    strextend (&command, "-statmode %s", STATMODE);
+    strextend (&command, "-D CAMERA %s", CAMERA);
+    strextend (&command, "-D STAR_TOOFEW %d", STAR_TOOFEW);
+    strextend (&command, "-minerror %f", MIN_ERROR);
+    strextend (&command, "-cloud-limit %f", CLOUD_TOLERANCE);
 
-    if (VERBOSE)       	     strextend (command, "-v");
-    if (VERBOSE2)      	     strextend (command, "-vv");
-    if (RESET)         	     strextend (command, "-reset");
-    if (RESET_ZEROPTS) 	     strextend (command, "-reset-zpts");
-    if (!KEEP_UBERCAL) 	     strextend (command, "-reset-ubercal");
-    if (DophotSelect)  	     strextend (command, "-dophot %d", DophotValue);
-    if (ImagSelect)    	     strextend (command, "-instmag %f %f", ImagMin, ImagMax);
-    if (MaxDensityUse) 	     strextend (command, "-max-density %f", MaxDensityValue);
-    if (SyntheticPhotometry) strextend (command, "-synthphot");
+    if (VERBOSE)       	     strextend (&command, "-v");
+    if (VERBOSE2)      	     strextend (&command, "-vv");
+    if (RESET)         	     strextend (&command, "-reset");
+    if (RESET_ZEROPTS) 	     strextend (&command, "-reset-zpts");
+    if (!KEEP_UBERCAL) 	     strextend (&command, "-reset-ubercal");
+    if (DophotSelect)  	     strextend (&command, "-dophot %d", DophotValue);
+    if (ImagSelect)    	     strextend (&command, "-instmag %f %f", ImagMin, ImagMax);
+    if (MaxDensityUse) 	     strextend (&command, "-max-density %f", MaxDensityValue);
+    if (SyntheticPhotometry) strextend (&command, "-synthphot");
 
-    if (UPDATE)        	     strextend (command, "-update");
-    if (MOSAIC_ZEROPT) 	     strextend (command, "-mosaic");
-    if (FREEZE_IMAGES) 	     strextend (command, "-imfreeze");
-    if (FREEZE_MOSAICS)	     strextend (command, "-mosfreeze");
-    if (PARALLEL)      	     strextend (command, "-parallel");
-    if (PARALLEL_MANUAL)     strextend (command, "-parallel-manual");
-    if (PARALLEL_SERIAL)     strextend (command, "-parallel-serial");
+    if (UPDATE)        	     strextend (&command, "-update");
+    if (MOSAIC_ZEROPT) 	     strextend (&command, "-mosaic");
+    if (FREEZE_IMAGES) 	     strextend (&command, "-imfreeze");
+    if (FREEZE_MOSAICS)	     strextend (&command, "-mosfreeze");
+    if (PARALLEL)      	     strextend (&command, "-parallel");
+    if (PARALLEL_MANUAL)     strextend (&command, "-parallel-manual");
+    if (PARALLEL_SERIAL)     strextend (&command, "-parallel-serial");
 
     // XXX deprecate this if we are happy with the new version
-    if (SET_MREL_VERSION != 1) strextend (command, "-set-mrel-version %d", SET_MREL_VERSION);
+    // if (SET_MREL_VERSION != 1) strextend (command, "-set-mrel-version %d", SET_MREL_VERSION);
 
     fprintf (stderr, "command: %s\n", command);
Index: /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/load_catalogs.c
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/load_catalogs.c	(revision 38444)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/load_catalogs.c	(revision 38445)
@@ -34,4 +34,5 @@
     // XXX keep in mind that not all catalogs are loaded
     dvo_catalog_init (&catalog[i], TRUE);
+    dvo_catalog_init (&tcatalog, TRUE);
 
     // does this host ID match the desired location for the table?
@@ -41,10 +42,11 @@
     char hostfile[1024];
     snprintf (hostfile, 1024, "%s/%s.cpt", hostpath, skylist[0].regions[i]->name);
-    tcatalog.filename = hostID ? hostfile : skylist[0].filename[i];
-
-    tcatalog.catformat = dvo_catalog_catformat (CATFORMAT);    // set the default catformat from config data
-    tcatalog.catmode   = dvo_catalog_catmode (CATMODE);        // set the default catmode from config data
-    tcatalog.catflags  = LOAD_AVES | LOAD_MEAS | LOAD_SECF;    // don't need to load all data at this point
-    tcatalog.Nsecfilt  = GetPhotcodeNsecfilt ();               // set the desired number in case we need to create the catalog
+    tcatalog.filename    = hostID ? hostfile : skylist[0].filename[i];
+    tcatalog.catflags    = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT;    // don't need to load all data at this point
+    tcatalog.Nsecfilt    = GetPhotcodeNsecfilt ();               // set the desired number in case we need to create the catalog
+
+    // tcatalog.catformat   = dvo_catalog_catformat (CATFORMAT);    // set the default catformat from config data
+    // tcatalog.catmode     = dvo_catalog_catmode (CATMODE);        // set the default catmode from config data
+    // tcatalog.catcompress = dvo_catalog_catcompress (CATCOMPRESS); // set the default catcompress from config data
 
     if (!dvo_catalog_open (&tcatalog, skylist[0].regions[i], VERBOSE2, "r")) {
@@ -52,5 +54,5 @@
       exit (1);
     }
-    if (!tcatalog.Naves_disk) {
+    if (!tcatalog.Naverage_disk) {
 	if (VERBOSE2) { fprintf (stderr, "no data in %s, skipping\n", tcatalog.filename); }
 	dvo_catalog_unlock (&tcatalog);
@@ -153,26 +155,24 @@
     // MaxDensityUse, MaxDensityValue
 
-    char command[1024];
-    snprintf (command, 1024, "relphot_client %s -load %s -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -D CAMERA %s -D MAG_LIM %f -D SIGMA_LIM %f", 
+    char *command = NULL;
+    strextend (&command, "relphot_client %s -load %s -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -D CAMERA %s -D MAG_LIM %f -D SIGMA_LIM %f", 
 	      PhotcodeList, table->hosts[i].results, table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, CAMERA, MAG_LIM, SIGMA_LIM);
 
-    char tmpline[1024];
-    if (VERBOSE)       	     { snprintf (tmpline, 1024, "%s -v",              command);                   strcpy (command, tmpline); }
-    if (VERBOSE2)      	     { snprintf (tmpline, 1024, "%s -vv",             command); 		  strcpy (command, tmpline); }
-    if (RESET)         	     { snprintf (tmpline, 1024, "%s -reset",          command); 		  strcpy (command, tmpline); }
-    if (RESET_ZEROPTS) 	     { snprintf (tmpline, 1024, "%s -reset-zpts",     command); 		  strcpy (command, tmpline); }
-    if (!KEEP_UBERCAL) 	     { snprintf (tmpline, 1024, "%s -reset-ubercal",  command); 		  strcpy (command, tmpline); }
-    if (DophotSelect)  	     { snprintf (tmpline, 1024, "%s -dophot %d",      command, DophotValue);      strcpy (command, tmpline); }
-    if (ImagSelect)    	     { snprintf (tmpline, 1024, "%s -instmag %f %f",  command, ImagMin, ImagMax); strcpy (command, tmpline); }
-    if (MaxDensityUse) 	     { snprintf (tmpline, 1024, "%s -max-density %f", command, MaxDensityValue);  strcpy (command, tmpline); }
-    if (SyntheticPhotometry) { snprintf (tmpline, 1024, "%s -synthphot",      command);                   strcpy (command, tmpline); }
+    if (VERBOSE)       	     { strextend (&command, "-v"); }
+    if (VERBOSE2)      	     { strextend (&command, "-vv"); }
+    if (RESET)         	     { strextend (&command, "-reset"); }
+    if (RESET_ZEROPTS) 	     { strextend (&command, "-reset-zpts"); }
+    if (!KEEP_UBERCAL) 	     { strextend (&command, "-reset-ubercal"); }
+    if (DophotSelect)  	     { strextend (&command, "-dophot %d", DophotValue); }
+    if (ImagSelect)    	     { strextend (&command, "-instmag %f %f", ImagMin, ImagMax); }
+    if (MaxDensityUse) 	     { strextend (&command, "-max-density %f", MaxDensityValue); }
+    if (SyntheticPhotometry) { strextend (&command, "-synthphot"); }
 
     if (TimeSelect) { 
       char *tstart = ohana_sec_to_date (TSTART);
       char *tstop  = ohana_sec_to_date (TSTOP);
-      snprintf (tmpline, 1024, "%s -time %s %s", command, tstart, tstop); 
+      strextend (&command, "-time %s %s", tstart, tstop); 
       free (tstart);
       free (tstop);
-      strcpy (command, tmpline); 
     }
 
Index: /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/load_images.c
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/load_images.c	(revision 38444)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/load_images.c	(revision 38445)
@@ -21,5 +21,5 @@
   // convert database table to internal structure (binary to Image)
   // 'image' points to the same memory as db->ftable->buffer
-  image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].swapped);
+  image = gfits_table_get_Image (&db[0].ftable, &Nimage, &db[0].scaledValue, &db[0].nativeOrder);
   if (!image) {
       fprintf (stderr, "ERROR: failed to read images\n");
Index: /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/reload_catalogs.c
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/reload_catalogs.c	(revision 38444)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/reload_catalogs.c	(revision 38445)
@@ -59,8 +59,9 @@
     TIMESTAMP(time1);
 
-    catalog.catformat = dvo_catalog_catformat (CATFORMAT);    // set the default catformat from config data
-    catalog.catmode   = dvo_catalog_catmode (CATMODE);        // set the default catmode from config data
-    catalog.catflags  = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
-    catalog.Nsecfilt  = GetPhotcodeNsecfilt ();               // set the desired number in case we need to create the catalog
+    // catalog.catformat   = dvo_catalog_catformat (CATFORMAT);    // set the default catformat from config data
+    // catalog.catmode     = dvo_catalog_catmode (CATMODE);        // set the default catmode from config data
+    // catalog.catcompress = dvo_catalog_catcompress (CATCOMPRESS); // set the default catcompress from config data
+    catalog.catflags    = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT;
+    catalog.Nsecfilt    = GetPhotcodeNsecfilt ();               // set the desired number in case we need to create the catalog
 
     if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "w")) {
@@ -69,5 +70,5 @@
       // exit (1);
     }
-    if (VERBOSE && (catalog.Naves_disk == 0)) {
+    if (VERBOSE && (catalog.Naverage_disk == 0)) {
 	fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
 	dvo_catalog_unlock (&catalog);
@@ -179,5 +180,5 @@
 
   int Ngroups;
-  HostTableGroup *groups = HostTableGroups (table, &Ngroups);
+  HostTableGroup *groups = HostTableGroupsUniqueMachines (table, &Ngroups);
   // split the table into Ngroups, each with a unique set of machines (this avoids overloading the remote host machines)
 
@@ -215,7 +216,11 @@
     group->hosts[i][0].pathname = tmppath;
 
-    char command[1024];
-    snprintf (command, 1024, "relphot_client %s -update-catalogs %s -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s -D CAMERA %s -D STAR_TOOFEW %d -minerror %f", 
-	      PhotcodeList, imageFile, group->hosts[i][0].hostID, CATDIR, group->hosts[i][0].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, STATMODE, CAMERA, STAR_TOOFEW, MIN_ERROR);
+    char *command = NULL;
+    strextend (&command, "relphot_client %s -update-catalogs %s", PhotcodeList, imageFile);
+    strextend (&command, "-hostID %d -D CATDIR %s -hostdir %s", group->hosts[i][0].hostID, CATDIR, group->hosts[i][0].pathname);
+    strextend (&command, "-region %f %f %f %f", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
+    strextend (&command, "-statmode %s", STATMODE);
+    strextend (&command, "-D CAMERA %s", CAMERA);
+    strextend (&command, "-D STAR_TOOFEW %d -minerror %f", STAR_TOOFEW, MIN_ERROR);
 
     // options & configs which affect relphot_client -update-catalogs
@@ -229,24 +234,25 @@
     // MIN_ERROR
     
-    char tmpline[1024];
-    if (VERBOSE)           { snprintf (tmpline, 1024, "%s -v",           	command);                    			  strcpy (command, tmpline); }
-    if (VERBOSE2)          { snprintf (tmpline, 1024, "%s -vv",          	command); 		     			  strcpy (command, tmpline); }
-    if (RESET)             { snprintf (tmpline, 1024, "%s -reset",       	command); 		     			  strcpy (command, tmpline); }
-    if (RESET_ZEROPTS)     { snprintf (tmpline, 1024, "%s -reset-zpts",       	command); 		     			  strcpy (command, tmpline); }
-    if (UPDATE)            { snprintf (tmpline, 1024, "%s -update",       	command); 		     			  strcpy (command, tmpline); }
-    if (IS_DIFF_DB)        { snprintf (tmpline, 1024, "%s -is-diff-db",       	command); 		     			  strcpy (command, tmpline); }
-    if (!KEEP_UBERCAL)     { snprintf (tmpline, 1024, "%s -reset-ubercal",	command); 		                          strcpy (command, tmpline); }
-    if (UPDATE_CATFORMAT)  { snprintf (tmpline, 1024, "%s -update-catformat %s", command, UPDATE_CATFORMAT); 		          strcpy (command, tmpline); }
-    if (BOUNDARY_TREE)     { snprintf (tmpline, 1024, "%s -boundary-tree %s",    command, BOUNDARY_TREE); 		          strcpy (command, tmpline); }
-    if (SYNTH_ZERO_POINTS) { snprintf (tmpline, 1024, "%s -synthphot-zpts %s", command, SYNTH_ZERO_POINTS); strcpy (command, tmpline); }
-    if (SET_MREL_VERSION != 1) { snprintf (tmpline, 1024, "%s -set-mrel-version %d", command, SET_MREL_VERSION);                  strcpy (command, tmpline); }
-    if (AreaSelect)       { snprintf (tmpline, 1024, "%s -area %f %f %f %f",    command, AreaXmin, AreaXmax, AreaYmin, AreaYmax); strcpy (command, tmpline); }
+    if (VERBOSE)          { strextend (&command, "-v"); }
+    if (VERBOSE2)         { strextend (&command, "-vv"); }
+    if (RESET)            { strextend (&command, "-reset"); }
+    if (RESET_ZEROPTS)    { strextend (&command, "-reset-zpts"); }
+    if (UPDATE)           { strextend (&command, "-update"); }
+    if (IS_DIFF_DB)       { strextend (&command, "-is-diff-db"); }
+    if (!KEEP_UBERCAL)    { strextend (&command, "-reset-ubercal"); }
+    if (UPDATE_CATFORMAT) { strextend (&command, "-update-catformat %s", UPDATE_CATFORMAT); }
+    if (BOUNDARY_TREE)    { strextend (&command, "-boundary-tree %s", BOUNDARY_TREE); }
+    if (SYNTH_ZERO_POINTS) { strextend {&command, "-synthphot-zpts %s", SYNTH_ZERO_POINTS); }
+
+    // deprecate
+    // if (SET_MREL_VERSION != 1) { snprintf (tmpline, 1024, "%s -set-mrel-version %d", SET_MREL_VERSION); } // XXXX deprecate this...
+
+    if (AreaSelect)       { strextend (&command, "-area %f %f %f %f", AreaXmin, AreaXmax, AreaYmin, AreaYmax); }
     if (TimeSelect) { 
       char *tstart = ohana_sec_to_date (TSTART);
       char *tstop  = ohana_sec_to_date (TSTOP);
-      snprintf (tmpline, 1024, "%s -time %s %s", command, tstart, tstop); 
+      strextend (&command, "-time %s %s", tstart, tstop); 
       free (tstart);
       free (tstop);
-      strcpy (command, tmpline); 
     }
 
Index: /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/relphot_images.c
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/relphot_images.c	(revision 38444)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/relphot_images.c	(revision 38445)
@@ -18,4 +18,5 @@
   /* register database handle with shutdown procedure */
   set_db (&db);
+  gfits_db_init (&db);
   db.mode   = dvo_catalog_catmode (CATMODE);
   db.format = dvo_catalog_catformat (CATFORMAT);
@@ -185,5 +186,5 @@
       // convert database table to internal structure (binary to Image)
       // 'image' points to the same memory as db->ftable->buffer
-      image = gfits_table_get_Image (&db.ftable, &Nimage, &db.swapped);
+      image = gfits_table_get_Image (&db.ftable, &Nimage, &db.scaledValue, &db.nativeOrder);
       if (!image) {
 	fprintf (stderr, "ERROR: failed to read images\n");
Index: /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/relphot_objects.c
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/relphot_objects.c	(revision 38444)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/relphot_objects.c	(revision 38445)
@@ -42,9 +42,10 @@
     char hostfile[1024];
     snprintf (hostfile, 1024, "%s/%s.cpt", hostpath, skylist[0].regions[i]->name);
-    catalog.filename  = hostID ? hostfile : skylist[0].filename[i];
-    catalog.catformat = dvo_catalog_catformat (CATFORMAT);    // set the default catformat from config data
-    catalog.catmode   = dvo_catalog_catmode (CATMODE);        // set the default catmode from config data
-    catalog.catflags  = LOAD_AVES | LOAD_MEAS | LOAD_MISS | LOAD_SECF;
-    catalog.Nsecfilt  = GetPhotcodeNsecfilt ();
+    catalog.filename    = hostID ? hostfile : skylist[0].filename[i];
+    // catalog.catformat   = dvo_catalog_catformat (CATFORMAT);    // set the default catformat from config data
+    // catalog.catmode     = dvo_catalog_catmode (CATMODE);        // set the default catmode from config data
+    // catalog.catcompress = dvo_catalog_catcompress (CATCOMPRESS); // set the default catcompress from config data
+    catalog.catflags    = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_MISSING | DVO_LOAD_SECFILT;
+    catalog.Nsecfilt    = GetPhotcodeNsecfilt ();
 
     if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "w")) {
@@ -52,5 +53,5 @@
       exit (1);
     }
-    if (!catalog.Naves_disk) {
+    if (!catalog.Naverage_disk) {
       if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
       dvo_catalog_unlock (&catalog);
@@ -143,17 +144,17 @@
     // MaxDensityUse, MaxDensityValue
 
-    char command[1024];
-    snprintf (command, 1024, "relphot_client -update-objects -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s -D CAMERA %s -D STAR_TOOFEW %d -minerror %f", 
+    char *command = NULL;
+    strextend (&command, "relphot_client -update-objects -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f -statmode %s -D CAMERA %s -D STAR_TOOFEW %d -minerror %f", 
 	      table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax, STATMODE, CAMERA, STAR_TOOFEW, MIN_ERROR);
 
-    char tmpline[1024];
-    if (VERBOSE)       { snprintf (tmpline, 1024, "%s -v",              command);                    strcpy (command, tmpline); }
-    if (VERBOSE2)      { snprintf (tmpline, 1024, "%s -vv",             command); 		     strcpy (command, tmpline); }
-    if (RESET)         { snprintf (tmpline, 1024, "%s -reset",          command); 		     strcpy (command, tmpline); }
-    if (RESET_ZEROPTS) { snprintf (tmpline, 1024, "%s -reset-zpts",     command); 		     strcpy (command, tmpline); }
-    if (UPDATE)        { snprintf (tmpline, 1024, "%s -update",         command); 		     strcpy (command, tmpline); }
-    if (!KEEP_UBERCAL) { snprintf (tmpline, 1024, "%s -reset-ubercal",  command); 		     strcpy (command, tmpline); }
-    if (SET_MREL_VERSION != 1) { snprintf (tmpline, 1024, "%s -set-mrel-version %d", command, SET_MREL_VERSION); strcpy (command, tmpline); }
+    if (VERBOSE)       { strextend (&command, "-v"); }
+    if (VERBOSE2)      { strextend (&command, "-vv"); }
+    if (RESET)         { strextend (&command, "-reset"); }
+    if (RESET_ZEROPTS) { strextend (&command, "-reset-zpts"); }
+    if (UPDATE)        { strextend (&command, "-update"); }
+    if (!KEEP_UBERCAL) { strextend (&command, "-reset-ubercal"); }
     if (SYNTH_ZERO_POINTS) { snprintf (tmpline, 1024, "%s -synthphot-zpts %s", command, SYNTH_ZERO_POINTS); strcpy (command, tmpline); }
+
+    // if (SET_MREL_VERSION != 1) { strextend (&command, "-set-mrel-version %d", SET_MREL_VERSION); } 
 
     fprintf (stderr, "command: %s\n", command);
Index: /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/relphot_parallel_regions.c
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/relphot_parallel_regions.c	(revision 38444)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/relphot_parallel_regions.c	(revision 38445)
@@ -23,4 +23,5 @@
   // register database handle with shutdown procedure
   set_db (&db);
+  gfits_db_init (&db);
   db.mode   = dvo_catalog_catmode (CATMODE);
   db.format = dvo_catalog_catformat (CATFORMAT);
Index: /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/relphot_synthphot.c
===================================================================
--- /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/relphot_synthphot.c	(revision 38444)
+++ /branches/eam_branches/ipp-20150419/Ohana/src/relphot/src/relphot_synthphot.c	(revision 38445)
@@ -41,9 +41,10 @@
     char hostfile[1024];
     snprintf (hostfile, 1024, "%s/%s.cpt", hostpath, skylist[0].regions[i]->name);
-    catalog.filename  = hostID ? hostfile : skylist[0].filename[i];
-    catalog.catformat = dvo_catalog_catformat (CATFORMAT);    // set the default catformat from config data
-    catalog.catmode   = dvo_catalog_catmode (CATMODE);        // set the default catmode from config data
-    catalog.catflags  = LOAD_AVES | LOAD_MEAS | LOAD_SECF;
-    catalog.Nsecfilt  = GetPhotcodeNsecfilt ();
+    catalog.filename    = hostID ? hostfile : skylist[0].filename[i];
+    // catalog.catformat   = dvo_catalog_catformat (CATFORMAT);    // set the default catformat from config data
+    // catalog.catmode     = dvo_catalog_catmode (CATMODE);        // set the default catmode from config data
+    // catalog.catcompress = dvo_catalog_catcompress (CATCOMPRESS); // set the default catcompress from config data
+    catalog.catflags    = DVO_LOAD_AVERAGE | DVO_LOAD_MEASURE | DVO_LOAD_SECFILT;
+    catalog.Nsecfilt    = GetPhotcodeNsecfilt ();
 
     if (!dvo_catalog_open (&catalog, skylist[0].regions[i], VERBOSE, "w")) {
@@ -51,5 +52,5 @@
       exit (1);
     }
-    if (!catalog.Naves_disk) {
+    if (!catalog.Naverage_disk) {
       if (VERBOSE) fprintf (stderr, "no data in %s, skipping\n", catalog.filename);
       dvo_catalog_unlock (&catalog);
@@ -110,12 +111,12 @@
     // VERBOSE, VERBOSE2
 
-    char command[1024];
-    snprintf (command, 1024, "relphot_client -synthphot_means %s -hostID %d -D CATDIR %s -hostdir %s -region %f %f %f %f", 
-	      SYNTH_ZERO_POINTS, table->hosts[i].hostID, CATDIR, table->hosts[i].pathname, UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
+    char *command = NULL;
+    strextend (&command, "relphot_client -synthphot_means %s", SYNTH_ZERO_POINTS);
+    strextend (&command, "-hostID %d -D CATDIR %s -hostdir %s", table->hosts[i].hostID, CATDIR, table->hosts[i].pathname);
+    strextend (&command, "-region %f %f %f %f", UserPatch.Rmin, UserPatch.Rmax, UserPatch.Dmin, UserPatch.Dmax);
 
-    char tmpline[1024];
-    if (VERBOSE)       { snprintf (tmpline, 1024, "%s -v",              command);                    strcpy (command, tmpline); }
-    if (VERBOSE2)      { snprintf (tmpline, 1024, "%s -vv",             command); 		     strcpy (command, tmpline); }
-    if (UPDATE)        { snprintf (tmpline, 1024, "%s -update",         command); 		     strcpy (command, tmpline); }
+    if (VERBOSE)       { strextend (&command, "-v");      }
+    if (VERBOSE2)      { strextend (&command, "-vv");     }
+    if (UPDATE)        { strextend (&command, "-update"); }
 
     fprintf (stderr, "command: %s\n", command);
