Index: branches/eam_branches/ipp-20140206/Ohana/src/libdvo/include/dvo.h
===================================================================
--- branches/eam_branches/ipp-20140206/Ohana/src/libdvo/include/dvo.h	(revision 36536)
+++ branches/eam_branches/ipp-20140206/Ohana/src/libdvo/include/dvo.h	(revision 36545)
@@ -416,4 +416,5 @@
   uint32_t       flags;
   int            catID;
+  int            objID;
   int            nOwn;
 } AverageTiny;
Index: branches/eam_branches/ipp-20140206/Ohana/src/libdvo/src/dvo_convert_PS1_V4.c
===================================================================
--- branches/eam_branches/ipp-20140206/Ohana/src/libdvo/src/dvo_convert_PS1_V4.c	(revision 36536)
+++ branches/eam_branches/ipp-20140206/Ohana/src/libdvo/src/dvo_convert_PS1_V4.c	(revision 36545)
@@ -549,4 +549,5 @@
 }
 
+// XXX note that there are 2 bad versions of PS1_V4 : the other one does have have PSF_QF_PERFECT, but has PAD instead
 int gfits_convert_Measure_PS1_V4alt (Measure_PS1_V4alt *data, off_t size, off_t nitems) {
 
@@ -708,5 +709,5 @@
 # ifdef BYTE_SWAP
   byte = (unsigned char *) data;
-  for (i = 0; i < nitems; i++, byte += 129) {
+  for (i = 0; i < nitems; i++, byte += 120) {
     /** BYTE SWAP **/
     SWAP_DBLE (0); // RA
@@ -754,5 +755,5 @@
   Ncols = ftable[0].header[0].Naxis[0];
   if (Ncols != 120) {
-    fprintf (stderr, "ERROR: mis-match in table size: width is %d but should be %d bytes\n", Ncols, 176);
+    fprintf (stderr, "ERROR: mis-match in table size: width is %d but should be %d bytes\n", Ncols, 120);
     return NULL;
   }
Index: branches/eam_branches/ipp-20140206/Ohana/src/libdvo/src/dvo_tiny_values.c
===================================================================
--- branches/eam_branches/ipp-20140206/Ohana/src/libdvo/src/dvo_tiny_values.c	(revision 36536)
+++ branches/eam_branches/ipp-20140206/Ohana/src/libdvo/src/dvo_tiny_values.c	(revision 36545)
@@ -8,4 +8,6 @@
   averageT[0].measureOffset = average[0].measureOffset;
   averageT[0].catID         = average[0].catID;
+  averageT[0].objID         = average[0].objID;
+  averageT[0].nOwn          = -1;
   return;
 }
@@ -33,4 +35,5 @@
   measureT[0].dYccd      = measure[0].dYccd;
   measureT[0].dRsys      = measure[0].dRsys;
+  measureT[0].myDet      = 0;
   return ;
 }
Index: branches/eam_branches/ipp-20140206/Ohana/src/relphot/Makefile
===================================================================
--- branches/eam_branches/ipp-20140206/Ohana/src/relphot/Makefile	(revision 36536)
+++ branches/eam_branches/ipp-20140206/Ohana/src/relphot/Makefile	(revision 36545)
@@ -54,4 +54,5 @@
 $(SRC)/ImageTable.$(ARCH).o	 \
 $(SRC)/ImageMagIO.$(ARCH).o	 \
+$(SRC)/syncfile.$(ARCH).o	 \
 $(SRC)/share_image_mags.$(ARCH).o	 \
 $(SRC)/share_mean_mags.$(ARCH).o	 \
Index: branches/eam_branches/ipp-20140206/Ohana/src/relphot/include/relphot.h
===================================================================
--- branches/eam_branches/ipp-20140206/Ohana/src/relphot/include/relphot.h	(revision 36536)
+++ branches/eam_branches/ipp-20140206/Ohana/src/relphot/include/relphot.h	(revision 36545)
@@ -477,10 +477,12 @@
 int catID_and_objID_to_seq (int catID, int objID, int *catSeq, off_t *objSeq);
 
+int check_sync_file (char *filename, int nloop);
+int clear_sync_file (char *filename);
+int update_sync_file (char *filename, int nloop);
+char *make_filename (char *dirname, char *hostname, int hostID, char *tailname);
+
 int share_mean_mags (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop);
 int slurp_mean_mags (Catalog *catalog, int Ncatalog, RegionHostTable *regionHosts, int nloop);
-int check_sync_file (char *hostname, int nloop);
-int clear_sync_file (char *hostname);
-int update_sync_file (char *hostname, int nloop);
-int set_mean_mags (MeanMag *meanmags, Average *average, SecFilt *secfilt, int Nsec);
+int set_mean_mags (MeanMag *meanmags, AverageTiny *average, SecFilt *secfilt, int Nsec);
 MeanMag *merge_mean_mags (MeanMag *target, int *ntarget, MeanMag *source, int Nsource);
 
@@ -490,7 +492,4 @@
 int share_image_mags (RegionHostTable *regionHosts, int nloop);
 int slurp_image_mags (RegionHostTable *regionHosts, int nloop);
-int check_imsync_file (char *hostname, int nloop);
-int update_imsync_file (char *hostname, int nloop);
-int clear_imsync_file (char *hostname);
 int set_image_mags (ImageMag *image_mags, Image *image);
 ImageMag *merge_image_mags (ImageMag *target, int *ntarget, ImageMag *source, int Nsource);
Index: branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/ImageMagIO.c
===================================================================
--- branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/ImageMagIO.c	(revision 36536)
+++ branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/ImageMagIO.c	(revision 36545)
@@ -119,8 +119,8 @@
   gfits_define_bintable_column (&theader, "E", "MCAL_SYSERR",    "systematic error", "magnitudes", 1.0, 0.0);
   gfits_define_bintable_column (&theader, "E", "CHISQ",          "cal chisq", "unitless", 1.0, 0.0);
-  gfits_define_bintable_column (&theader, "E", "NFIT",           "number of fitted stars", "unitless", 1.0, 0.0);
-  gfits_define_bintable_column (&theader, "E", "FLAGS",          "analysis flags", "unitless", 1.0, 0.0);
-  gfits_define_bintable_column (&theader, "E", "UDIST",          "distance to ubercal images", "images", 1.0, 0.0);
-  gfits_define_bintable_column (&theader, "E", "ID",             "image ID", "unitless", 1.0, 0.0);
+  gfits_define_bintable_column (&theader, "J", "NFIT",           "number of fitted stars", "unitless", 1.0, 0.0);
+  gfits_define_bintable_column (&theader, "J", "FLAGS",          "analysis flags", "unitless", 1.0, 0.0);
+  gfits_define_bintable_column (&theader, "J", "UDIST",          "distance to ubercal images", "images", 1.0, 0.0);
+  gfits_define_bintable_column (&theader, "J", "ID",             "image ID", "unitless", 1.0, 0.0);
 
   // generate the output array that carries the data
Index: branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/MeanMagIO.c
===================================================================
--- branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/MeanMagIO.c	(revision 36536)
+++ branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/MeanMagIO.c	(revision 36545)
@@ -74,5 +74,5 @@
     meanmags[i].catID          = catID[i];
   }
-  fprintf (stderr, "loaded data for %lld images\n", (long long) Nrow);
+  fprintf (stderr, "loaded data for %lld objects (* filters)\n", (long long) Nrow);
 
   free (M    );
Index: branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/StarOps.c
===================================================================
--- branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/StarOps.c	(revision 36536)
+++ branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/StarOps.c	(revision 36545)
@@ -917,6 +917,6 @@
     for (j = 0; j < catalog[i].Naverage; j++) {
       int nOwn = 0;
-      int m = catalog[i].average[j].measureOffset;
-      for (n = 0; n < catalog[i].average[j].Nmeasure; n++) {
+      int m = catalog[i].averageT[j].measureOffset;
+      for (n = 0; n < catalog[i].averageT[j].Nmeasure; n++) {
 	if (!catalog[i].measureT[m+n].myDet) continue;
 	nOwn ++;
@@ -925,4 +925,23 @@
     }
   }
+  return TRUE;
+}
+
+int dumpObjects (char *filename, Catalog *catalog, int Ncatalog) {
+
+  int i, n;
+  off_t j;
+
+  FILE *ftest = fopen (filename, "w");
+
+  for (i = 0; i < Ncatalog; i++) {
+    for (j = 0; j < catalog[i].Naverage; j++) {
+      int m = catalog[i].averageT[j].measureOffset;
+      for (n = 0; n < catalog[i].averageT[j].Nmeasure; n++) {
+	fprintf (ftest, "%08x %08x %10.6f %10.6f  %3d %1d\n", catalog[i].averageT[j].catID, catalog[i].averageT[j].objID, catalog[i].averageT[j].R, catalog[i].averageT[j].D, catalog[i].averageT[j].Nmeasure, catalog[i].measureT[m+n].myDet); 
+      }
+    }
+  }
+  fclose (ftest);
   return TRUE;
 }
Index: branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/indexCatalog.c
===================================================================
--- branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/indexCatalog.c	(revision 36536)
+++ branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/indexCatalog.c	(revision 36545)
@@ -1,15 +1,15 @@
 # include "relphot.h"
 
+static int   catIDmax = 0;
 static int  *catIDseq = NULL;
+static int  *objIDmax = NULL;
 static int **objIDseq = NULL;
 
 int indexCatalogs (Catalog *catalog, int Ncatalog) {
 
-  // find the max value of catID
-  int catIDmax = 0;
-
   int i;
   off_t j;
 
+  // find the max value of catID
   for (i = 0; i < Ncatalog; i++) {
     catIDmax = MAX (catalog[i].catID, catIDmax);
@@ -26,18 +26,19 @@
   }
   
+  ALLOCATE (objIDmax, int,   Ncatalog);
   ALLOCATE (objIDseq, int *, Ncatalog);
   for (i = 0; i < Ncatalog; i++) {
-    int objIDmax = 0;
+    objIDmax[i] = 0;
     for (j = 0; j < catalog[i].Naverage; j++) {
-      objIDmax = MAX (catalog[i].average[j].objID, objIDmax);
+      objIDmax[i] = MAX (catalog[i].averageT[j].objID, objIDmax[i]);
     }
 
-    ALLOCATE (objIDseq[i], int, objIDmax + 1);
-    for (j = 0; j < objIDmax + 1; j++) {
+    ALLOCATE (objIDseq[i], int, objIDmax[i] + 1);
+    for (j = 0; j < objIDmax[i] + 1; j++) {
       objIDseq[i][j] = -1;
     }
 
     for (j = 0; j < catalog[i].Naverage; j++) {
-      int objID = catalog[i].average[j].objID;
+      int objID = catalog[i].averageT[j].objID;
       objIDseq[i][objID] = j;
     }
@@ -48,6 +49,10 @@
 int catID_and_objID_to_seq (int catID, int objID, int *catSeq, off_t *objSeq) {
 
+  if (catID > catIDmax) return FALSE;
+
   int cat = catIDseq[catID];
   if (cat < 1) return FALSE;
+
+  if (objID > objIDmax[cat]) return FALSE;
 
   int obj = objIDseq[cat][objID];
Index: branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/launch_region_hosts.c
===================================================================
--- branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/launch_region_hosts.c	(revision 36536)
+++ branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/launch_region_hosts.c	(revision 36545)
@@ -19,4 +19,27 @@
 
   int i;
+
+  // clear the I/O files
+  for (i = 0; i < regionHosts->Nhosts; i++) {
+    char *syncfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "meanmags.sync");
+    truncate (syncfile, 0);
+    free (syncfile);
+
+    char *fitsfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "meanmags.fits");
+    truncate (fitsfile, 0);
+    free (fitsfile);
+
+    char *imsyncfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "imagemags.sync");
+    truncate (imsyncfile, 0);
+    free (imsyncfile);
+
+    char *imfitsfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "imagemags.fits");
+    truncate (imfitsfile, 0);
+    free (imfitsfile);
+
+    char *loopsyncfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "loop.sync");
+    truncate (loopsyncfile, 0);
+    free (loopsyncfile);
+  }
 
   for (i = 0; i < regionHosts->Nhosts; i++) {
@@ -48,4 +71,6 @@
     fprintf (stderr, "command: %s\n", command);
     
+    if (PARALLEL_MANUAL) continue;
+
     // launch the job on the remote machine (no handshake)
     int errorInfo = 0;
@@ -58,6 +83,10 @@
   }
 
-  // XXX probably need an alternate function here...
-  RegionHostTableWaitJobs (regionHosts, __FILE__, __LINE__);
+  if (PARALLEL_MANUAL) {
+    fprintf (stderr, "run the relphot_client commands above.  when these are done, hit return\n");
+    getchar();
+  } else {
+    RegionHostTableWaitJobs (regionHosts, __FILE__, __LINE__);
+  }
  
   return TRUE;
Index: branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/relphot_parallel_images.c
===================================================================
--- branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/relphot_parallel_images.c	(revision 36536)
+++ branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/relphot_parallel_images.c	(revision 36545)
@@ -9,4 +9,6 @@
  * update the unowned objects for owned detections 
  */
+
+int dumpObjects (char *filename, Catalog *catalog, int Ncatalog);
 
 int relphot_parallel_images () {
@@ -27,4 +29,9 @@
     exit (2);
   }
+
+  // XXX need to deal with mosaic vs image...
+  // initMosaics (image, Nimage...)
+
+  initImages (image, NULL, Nimage);
 
   // load the flat correction table (if defined)
@@ -56,4 +63,6 @@
   findMosaics (catalog, Ncatalog, TRUE);  /* also sets Grid values */
   MARKTIME("-- set up mosaic indexes: %f sec\n", dtime);
+
+  // dumpObjects ("test.obj.dat", catalog, Ncatalog);
 
   markObjects (catalog, Ncatalog);
@@ -104,4 +113,17 @@
   }
 
+  // this is a checkpoint to make sure all hosts have finished the loop above
+  int myHost = regionHosts->index[REGION_HOST_ID];
+  char *loopsyncfile = make_filename (CATDIR, regionHosts->hosts[myHost].hostname, REGION_HOST_ID, "loop.sync");
+  update_sync_file (loopsyncfile, 0);
+  free (loopsyncfile);
+
+  for (i = 0; i < regionHosts->Nhosts; i++) {
+    if (regionHosts->hosts[i].hostID == REGION_HOST_ID) continue;
+    char *loopsync = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "loop.sync");
+    check_sync_file (loopsync, 0);
+    free (loopsync);
+  }    
+
   /* set Mcal & Mmos for bad images */
   setMcal  (catalog, TRUE, flatcorr);
Index: branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/share_image_mags.c
===================================================================
--- branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/share_image_mags.c	(revision 36536)
+++ branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/share_image_mags.c	(revision 36545)
@@ -29,9 +29,11 @@
   char *hostname = regionHosts->hosts[myHost].hostname;
 
-  char filename[1024];
-  snprintf (filename, 1024, "%s/%s.imagemags.fits", CATDIR, hostname);
-  ImageMagSave (filename, image_mags, Nimage_mags);
+  char *imagfile = make_filename (CATDIR, hostname, REGION_HOST_ID, "imagemags.fits");
+  ImageMagSave (imagfile, image_mags, Nimage_mags);
+  free (imagfile);
 
-  update_imsync_file (hostname, nloop);
+  char *syncfile = make_filename (CATDIR, hostname, REGION_HOST_ID, "imagemags.sync");
+  update_sync_file (syncfile, nloop);
+  free (syncfile);
 
   return TRUE;
@@ -47,15 +49,18 @@
   ALLOCATE (image_mags, ImageMag, 1);
 
+  fprintf (stderr, "grabbing image mags from other hosts...\n");
+
   for (i = 0; i < regionHosts->Nhosts; i++) {
     if (regionHosts->hosts[i].hostID == REGION_HOST_ID) continue;
     // XXX add neighbor check? : if (not_neighbor(host[i])) continue;
 
-    check_imsync_file (regionHosts->hosts[i].hostname, nloop);
+    char *syncfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "imagemags.sync");
+    check_sync_file (syncfile, nloop);
+    free (syncfile);
     
-    char filename[1024];
-    snprintf (filename, 1024, "%s/%s.imagemags.fits", CATDIR, regionHosts->hosts[i].hostname);
-
     off_t Nsubset;
-    ImageMag *image_mags_subset = ImageMagLoad (regionHosts->hosts[i].hostname, &Nsubset);
+    char *imagfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "imagemags.fits");
+    ImageMag *image_mags_subset = ImageMagLoad (imagfile, &Nsubset);
+    free (imagfile);
 
     image_mags = merge_image_mags (image_mags, &Nimage_mags, image_mags_subset, Nsubset);
@@ -76,71 +81,6 @@
     images[seq].ubercalDist = image_mags[i].ubercalDist;
   }
-  return TRUE;
-}
 
-# define MSG_LENGTH 11
-
-int check_imsync_file (char *hostname, int nloop) {
-
-  char message[MSG_LENGTH];
-  char filename[1024];
-  sprintf (filename, "%s/%s.image.sync", CATDIR, hostname);
-
-  FILE *f = NULL; 
-
-  while (TRUE) {
-
-    f = fopen (filename, "r");
-    if (!f) {
-      usleep (2000000);
-      continue;
-    }
-
-    int Nread = fread (message, MSG_LENGTH, 1, f);
-    if (Nread < MSG_LENGTH) {
-      fclose (f);
-      usleep (2000000);
-      continue;
-    }
-    fclose (f);
-
-    // message is of the form: NLOOP: %03d
-    int loop;
-    sscanf (message, "%*s %d", &loop);
-    if (loop != nloop) {
-      usleep (2000000);
-      continue;
-    }
-    return TRUE;
-  }
-  return FALSE;
-}
-
-int update_imsync_file (char *hostname, int nloop) {
-
-  char message[MSG_LENGTH];
-  char filename[1024];
-  sprintf (filename, "%s/%s.image.sync", CATDIR, hostname);
-
-  FILE *f = fopen (filename, "w");
-  snprintf (message, 11, "NLOOP: %03d\n", nloop);
-  
-  int Nwrite = fwrite (message, MSG_LENGTH, 1, f);
-  if (Nwrite != MSG_LENGTH) {
-    fprintf (stderr, "failure to write sync message\n");
-    exit (3);
-  }
-
-  fclose (f);
-  return TRUE;
-}
-
-int clear_imsync_file (char *hostname) {
-
-  char filename[1024];
-  sprintf (filename, "%s/%s.image.sync", CATDIR, hostname);
-
-  // delete file contents
-  truncate (filename, 0);
+  fprintf (stderr, "DONE grabbing image mags from other hosts");
 
   return TRUE;
Index: branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/share_mean_mags.c
===================================================================
--- branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/share_mean_mags.c	(revision 36536)
+++ branches/eam_branches/ipp-20140206/Ohana/src/relphot/src/share_mean_mags.c	(revision 36545)
@@ -1,4 +1,3 @@
 # include "relphot.h"
-
 // we are sharing mean mags for all objects which (a) I own and (b) which have unowned detections
 
@@ -23,18 +22,18 @@
 
       // do I own this object? (in region range?)
-      if (catalog[i].average[j].R <  UserPatch.Rmin) continue;
-      if (catalog[i].average[j].R >= UserPatch.Rmax) continue;
-      if (catalog[i].average[j].D <  UserPatch.Dmin) continue;
-      if (catalog[i].average[j].D >= UserPatch.Dmax) continue;
+      if (catalog[i].averageT[j].R <  UserPatch.Rmin) continue;
+      if (catalog[i].averageT[j].R >= UserPatch.Rmax) continue;
+      if (catalog[i].averageT[j].D <  UserPatch.Dmin) continue;
+      if (catalog[i].averageT[j].D >= UserPatch.Dmax) continue;
 
       // does this object have missing detections (does someone else need it?)
       // XXX : sky objects without missing detections
       // XXX watch out for detections which are not associated with an image (REF)
-      if (catalog[i].averageT[j].nOwn != catalog[i].averageT[j].Nmeasure) continue;
+      if (catalog[i].averageT[j].nOwn == catalog[i].averageT[j].Nmeasure) continue;
 
       for (Ns = 0; Ns < Nphotcodes; Ns++) {
 	int thisCode = photcodes[Ns][0].code;
 	int Nsec = GetPhotcodeNsec(thisCode);
-	set_mean_mags (&meanmags[Nmeanmags], &catalog[i].average[j], &catalog[i].secfilt[Nsecfilt*j + Nsec], Nsec);
+	set_mean_mags (&meanmags[Nmeanmags], &catalog[i].averageT[j], &catalog[i].secfilt[Nsecfilt*j + Nsec], Nsec);
 	Nmeanmags ++;
 	CHECK_REALLOCATE (meanmags, MeanMag, NMEANMAGS, Nmeanmags, D_NMEANMAGS);
@@ -47,9 +46,11 @@
   char *hostname = regionHosts->hosts[myHost].hostname;
 
-  char filename[1024];
-  snprintf (filename, 1024, "%s/%s.meanmags.fits", CATDIR, hostname);
-  MeanMagSave (filename, meanmags, Nmeanmags);
+  char *magsfile = make_filename (CATDIR, hostname, REGION_HOST_ID, "meanmags.fits");
+  MeanMagSave (magsfile, meanmags, Nmeanmags);
+  free (magsfile);
 
-  update_sync_file (hostname, nloop);
+  char *syncfile = make_filename (CATDIR, hostname, REGION_HOST_ID, "meanmags.sync");
+  update_sync_file (syncfile, nloop);
+  free (syncfile);
 
   return TRUE;
@@ -64,4 +65,6 @@
   ALLOCATE (meanmags, MeanMag, 1);
 
+  fprintf (stderr, "grabbing mean object mags from other hosts...\n");
+
   int Nsecfilt = GetPhotcodeNsecfilt();
 
@@ -70,11 +73,12 @@
     if (regionHosts->hosts[i].hostID == REGION_HOST_ID) continue;
 
-    check_sync_file (regionHosts->hosts[i].hostname, nloop);
+    char *syncfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "meanmags.sync");
+    check_sync_file (syncfile, nloop);
+    free (syncfile);
     
-    char filename[1024];
-    snprintf (filename, 1024, "%s/%s.meanmags.fits", CATDIR, regionHosts->hosts[i].hostname);
-
     off_t Nsubset = 0;
-    MeanMag *meanmagsSubset = MeanMagLoad (regionHosts->hosts[i].hostname, &Nsubset);
+    char *magsfile = make_filename (CATDIR, regionHosts->hosts[i].hostname, regionHosts->hosts[i].hostID, "meanmags.fits");
+    MeanMag *meanmagsSubset = MeanMagLoad (magsfile, &Nsubset);
+    free (magsfile);
 
     // merge_mean_mags reallocs meanmags and frees the input meanmagsSubset
@@ -101,78 +105,11 @@
     catalog[catSeq].secfilt[objSeq*Nsecfilt + Nsec].M = meanmags[i].M;
   }
-  return TRUE;
-}
 
-# define MSG_LENGTH 11
-
-int check_sync_file (char *hostname, int nloop) {
-
-  char message[MSG_LENGTH];
-  char filename[1024];
-  sprintf (filename, "%s/%s.meanmags.sync", CATDIR, hostname);
-
-  // XXX I need a rule to generate the filename for each host
-  FILE *f = NULL; 
-
-  while (TRUE) {
-
-    f = fopen (filename, "r");
-    if (!f) {
-      usleep (2000000);
-      continue;
-    }
-
-    // XXX MSG_LENGTH : 0 EOL byte?
-    int Nread = fread (message, MSG_LENGTH, 1, f);
-    if (Nread < MSG_LENGTH) {
-      fclose (f);
-      usleep (2000000);
-      continue;
-    }
-    fclose (f);
-
-    // message is of the form: NLOOP: %03d
-    int loop;
-    sscanf (message, "%*s %d", &loop);
-    if (loop != nloop) {
-      usleep (2000000);
-      continue;
-    }
-    return TRUE;
-  }
-  return FALSE;
-}
-
-int clear_sync_file (char *hostname) {
-
-  char filename[1024];
-  sprintf (filename, "%s/%s.meanmags.sync", CATDIR, hostname);
-
-  // delete file contents
-  truncate (filename, 0);
+  fprintf (stderr, "DONE grabbing mean object mags from other hosts...\n");
 
   return TRUE;
 }
 
-int update_sync_file (char *hostname, int nloop) {
-
-  char message[MSG_LENGTH];
-  char filename[1024];
-  sprintf (filename, "%s/%s.meanmags.sync", CATDIR, hostname);
-
-  FILE *f = fopen (filename, "w");
-  snprintf (message, 11, "NLOOP: %03d\n", nloop);
-  
-  int Nwrite = fwrite (message, MSG_LENGTH, 1, f);
-  if (Nwrite != MSG_LENGTH) {
-    fprintf (stderr, "failure to write sync message\n");
-    exit (3);
-  }
-
-  fclose (f);
-  return TRUE;
-}
-
-int set_mean_mags (MeanMag *meanmags, Average *average, SecFilt *secfilt, int Nsec) {
+int set_mean_mags (MeanMag *meanmags, AverageTiny *average, SecFilt *secfilt, int Nsec) {
 
   meanmags->M  = secfilt->M;
