Index: /branches/eam_branches/ipp-20130306/Ohana/src/opihi/dvo/mextract.c
===================================================================
--- /branches/eam_branches/ipp-20130306/Ohana/src/opihi/dvo/mextract.c	(revision 35249)
+++ /branches/eam_branches/ipp-20130306/Ohana/src/opihi/dvo/mextract.c	(revision 35250)
@@ -147,4 +147,13 @@
     // 3) add the input subset filename to the dvo_client command
 
+    // allocate the temp array and copy all but (RA) (DEC)
+    int targc = 0;
+    char **targv = NULL;
+    ALLOCATE (targv, char *, argc);
+    for (i = 0; i < argc; i++) {
+      targv[targc] = strcreate (argv[i]);
+      targc ++;
+    }
+
     if (loadImages) {
       Image *image;
@@ -154,10 +163,13 @@
       char *filename = abspath("image.metadata.fits", DVO_MAX_PATH);
       ImageMetadataSave (filename, image, Nimage);
-      argc += 2;
-      argv[argc-2] = strcreate ("-image-metadata");
-      argv[argc-1] = strcreate (filename);
-    }
-
-    int status = HostTableParallelOps (argc, argv, RESULT_FILE, TRUE, 0, VERBOSE);
+
+      REALLOCATE (targv, char *, targc + 2);
+      targv[targc+0] = strcreate ("-image-metadata");
+      targv[targc+1] = strcreate (filename);
+      targc += 2;
+    }
+
+    // call the remote client
+    int status = HostTableParallelOps (targc, targv, RESULT_FILE, TRUE, 0, VERBOSE);
 
     dbFreeFields (fields, Nfields);
@@ -167,8 +179,9 @@
     dvo_catalog_free (&catalog);
 
-    if (loadImages) {
-      free (argv[argc-1]);
-      free (argv[argc-2]);
-    }
+    // free up targv
+    for (i = 0; i < targc; i++) {
+      free (targv[i]);
+    }
+    free (targv);
 
     return status;
Index: /branches/eam_branches/ipp-20130306/Ohana/src/opihi/dvo/mmatch.c
===================================================================
--- /branches/eam_branches/ipp-20130306/Ohana/src/opihi/dvo/mmatch.c	(revision 35249)
+++ /branches/eam_branches/ipp-20130306/Ohana/src/opihi/dvo/mmatch.c	(revision 35250)
@@ -49,4 +49,12 @@
   }
 
+  // load info about the images from a reduced-size file
+  char *imageMetadataFile = FALSE;
+  if ((N = get_argument (argc, argv, "-image-metadata"))) {
+    remove_argument (N, &argc, argv);
+    imageMetadataFile = strcreate (argv[N]);
+    remove_argument (N, &argc, argv);
+  }
+
   int PARALLEL = FALSE;
   if ((N = get_argument (argc, argv, "-parallel"))) {
@@ -75,4 +83,23 @@
   // HOST_ID tells library if operation is on remote client or not
   dbExtractMeasuresInit(HOST_ID);
+
+  // parse the fields to be extracted and returned
+  int first = 4;
+  if (CoordsFile) {
+    first = 2;
+  }
+  fields = dbCmdlineFields (argc-first, &argv[first], DVO_TABLE_MEASURE, &last, &Nfields);
+  if (fields == NULL) goto help;
+  if ((Nfields == 0) || (last != argc - first)) {
+    dbFreeFields (fields, Nfields);
+    dvo_catalog_free (&catalog);
+    goto help;
+  }
+
+  // load image data if needed (for fields listed below)
+  int loadImages = FALSE;
+  for (i = 0; !loadImages && (i < Nfields); i++) {
+    loadImages = field_needs_images (&fields[i]);
+  }
 
   // this does all the work of re-packaging the command, calling it on the remote machines, then loading in the results
@@ -124,4 +151,18 @@
       targc += 2;
     }      
+
+    if (loadImages) {
+      Image *image;
+      off_t Nimage;
+      if ((image = LoadImagesDVO (&Nimage)) == NULL) goto escape;
+
+      char *filename = abspath("image.metadata.fits", DVO_MAX_PATH);
+      ImageMetadataSave (filename, image, Nimage);
+
+      REALLOCATE (targv, char *, targc + 2);
+      targv[targc+0] = strcreate ("-image-metadata");
+      targv[targc+1] = strcreate (filename);
+      targc += 2;
+    }
 
     // call the remote client
@@ -155,24 +196,16 @@
   remove_argument (1, &argc, argv);
 
-  // parse the fields to be extracted and returned
-  fields = dbCmdlineFields (argc, argv, DVO_TABLE_MEASURE, &last, &Nfields);
-  if (fields == NULL) goto help;
-  if ((Nfields == 0) || (last != argc)) {
-    dbFreeFields (fields, Nfields);
-    dvo_catalog_free (&catalog);
-    goto help;
-  }
-
-  // load image data if needed (for fields listed below)
-  int loadImages = FALSE;
-  for (i = 0; !loadImages && (i < Nfields); i++) {
-    loadImages = field_needs_images (&fields[i]);
-  }
-
   // use the whole sky (since we select random points around the sky)
   SkyRegionSelection selection;
   selection.useDisplay = FALSE;
   selection.useSkyregion = FALSE;
-  if (loadImages && !SetImageSelection (TRUE, &selection)) goto escape;
+
+  if (loadImages) {
+    if (HOST_ID) {
+      if (!SetImageMetadataSelection (imageMetadataFile)) goto escape;
+    } else {
+      if (!SetImageSelection (TRUE, &selection)) goto escape;
+    }
+  }
 
   /* load regions which contain all supplied RA,DEC coordinates */
@@ -309,4 +342,6 @@
   if (invec) FreeVectorArray (invec, Ninvec);
   dbFreeFields (fields, Nfields);
+  FreeImageSelection ();
+  FreeImageMetadataSelection ();
   SkyListFree (skylist);
   return (TRUE);
@@ -317,4 +352,6 @@
   if (invec) FreeVectorArray (invec, Ninvec);
   dbFreeFields (fields, Nfields);
+  FreeImageSelection ();
+  FreeImageMetadataSelection ();
   SkyListFree (skylist);
   return (FALSE);
Index: /branches/eam_branches/ipp-20130306/Ohana/src/opihi/dvo/test/mmatch.sh
===================================================================
--- /branches/eam_branches/ipp-20130306/Ohana/src/opihi/dvo/test/mmatch.sh	(revision 35249)
+++ /branches/eam_branches/ipp-20130306/Ohana/src/opihi/dvo/test/mmatch.sh	(revision 35250)
@@ -10,5 +10,5 @@
   $Ro = 2.59
   $Do = 1.23
-  catdir /data/pikake.0/eugene/src/ipp-dev/Ohana/src/dvomerge/test/catdir.merge
+  catdir catdir.merge
   $Gname = g
   $Rname = r
@@ -21,5 +21,7 @@
   subset r_ave = $Rname  if (ra > $Ro - 0.1) && (ra > $Ro + 0.1) && (dec > $Do - 0.1) && (dec < $Do + 0.1)
   vectors 
-  mmatch -v -parallel R D 1.0 RA DEC MAG PHOTCODE -index index
+
+  # mmatch -v -parallel R D 1.0 RA DEC MAG PHOTCODE -index index
+  mmatch -v -parallel R D 1.0 RA DEC MAG PHOTCODE externID mean_airmass -index index
 
   reindex g_ave_match = g_ave using index
