Index: trunk/Ohana/src/opihi/dvo/mmatch.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/mmatch.c	(revision 34462)
+++ trunk/Ohana/src/opihi/dvo/mmatch.c	(revision 34463)
@@ -78,4 +78,22 @@
   DECvec = NULL;
   if (PARALLEL && !HOST_ID) {
+
+    // We need to copy the args to a temp array and modify them so that we send the
+    // correct set to the remote client.  The args list looks like this:
+    // if (!CoordsFile) : mmatch (RA) (DEC) (RADIUS) field, ...
+    // if ( CoordsFile) : mmatch (RADIUS) field, ... [because we stripped off the -coords filename elements]
+
+    // allocate the temp array and copy all but (RA) (DEC)
+    int targc = 0;
+    char **targv = NULL;
+    ALLOCATE (targv, char *, argc + 2);
+    for (i = 0; i < argc; i++) {
+      if (!CoordsFile && (i == 1)) continue;
+      if (!CoordsFile && (i == 2)) continue;
+      targv[targc] = strcreate (argv[i]);
+      targc ++;
+    }
+
+    // if not specified, create the coords.fits input file
     if (!CoordsFile) {
       // get vectors corresponding to coordinates of interest
@@ -92,18 +110,26 @@
     }
 
-    char *targv1 = argv[1];
-    char *targv2 = argv[2];
-    argv[1] = strcreate ("-coords");
-    argv[2] = strcreate (CoordsFile);
-    free (CoordsFile);
-
-    // I need to pass the RA & DEC vectors to the remote clients...
-    int status = HostTableParallelOps (argc, argv, RESULT_FILE, 0, VERBOSE);
+    // add the coords file to the args list
+    targv[targc+0] = strcreate ("-coords");
+    targv[targc+1] = CoordsFile; // this gets freed with targv
+    targc += 2;
+    
+    // if needed, add the index vector to the args list
+    if (IDXvec) {
+      REALLOCATE (targv, char *, targc + 2);
+      targv[targc+0] = strcreate ("-index");
+      targv[targc+1] = strcreate (IDXvec[0].name);
+      targc += 2;
+    }      
+
+    // call the remote client
+    int status = HostTableParallelOps (targc, targv, RESULT_FILE, 0, VERBOSE);
     if (vec) free (vec);
     
-    free (argv[1]);
-    free (argv[2]);
-    argv[1] = targv1;
-    argv[2] = targv2;
+    // free up targv
+    for (i = 0; i < targc; i++) {
+      free (targv[i]);
+    }
+    free (targv);
 
     return status;
@@ -278,9 +304,11 @@
   // only write the fields which were in a valid catalog
   if (RESULT_FILE) {
-    // extend the array by one to hold index array
-    REALLOCATE (vec, Vector *, Nfields + 1);
-    vec[Nfields] = IDXvec;
-
-    int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nfields + 1, FALSE, NULL);
+    if (IDXvec) {
+      // extend the array by one to hold index array
+      Nfields ++;
+      REALLOCATE (vec, Vector *, Nfields);
+      vec[Nfields-1] = IDXvec;
+    }
+    int status = WriteVectorTableFITS (RESULT_FILE, "RESULT", vec, Nfields, FALSE, NULL);
     if (!status) goto escape;
   }
