Index: trunk/Ohana/src/addstar/src/find_matches.c
===================================================================
--- trunk/Ohana/src/addstar/src/find_matches.c	(revision 26258)
+++ trunk/Ohana/src/addstar/src/find_matches.c	(revision 26277)
@@ -7,5 +7,5 @@
   double *X1, *Y1, *X2, *Y2;
   double dX, dY, dR;
-  int *N1, *N2,  *next_meas;
+  int *N1, *N2, *next_meas;
   int Nave, NAVE, Nmeas, NMEAS, Nmatch;
   int Nsecfilt, Nsec;
@@ -24,5 +24,5 @@
   ALLOCATE (X1, double, NstarsIn);
   ALLOCATE (Y1, double, NstarsIn);
-  ALLOCATE (N1, int,   NstarsIn);
+  ALLOCATE (N1, int,    NstarsIn);
 
   /** allocate local arrays (catalog) **/
@@ -338,7 +338,9 @@
   free (Y1);
   free (N1);
+  free (N2);
   free (X2);
   free (Y2);
-  free (N2);
+  free (next_meas);
+
   return (Nmatch);
 }
Index: trunk/Ohana/src/addstar/src/find_matches_closest.c
===================================================================
--- trunk/Ohana/src/addstar/src/find_matches_closest.c	(revision 26258)
+++ trunk/Ohana/src/addstar/src/find_matches_closest.c	(revision 26277)
@@ -24,5 +24,5 @@
   ALLOCATE (X1, double, NstarsIn);
   ALLOCATE (Y1, double, NstarsIn);
-  ALLOCATE (N1, int,   NstarsIn);
+  ALLOCATE (N1, int,    NstarsIn);
 
   /** allocate local arrays (catalog) **/
@@ -42,9 +42,8 @@
   catID = catalog[0].catID;
 
-  /* project onto rectilinear grid with 1 arcsec pixels. the choice of ZEA projection has the
-   * advantage that every point in R,D has a mapping to a unique X,Y.  However, note that not all
-   * possible X,Y points map back to R,D and the local plate scale changes substantially far from
-   * the projection pole.  a better mapping might be ARC, not yet implemented (see
-   * coordops.update.c).  We use the center of the region (catalog) for crval1,2. 
+  /* project onto rectilinear grid with 1 arcsec pixels. the choice of ARC projection has
+   * the advantage that every point in R,D has a mapping to a unique X,Y.  However, note
+   * that not all possible X,Y points map back to R,D and the local plate scale changes
+   * far from the projection pole. We use the center of the region (catalog) for crval1,2.
    */
   tcoords.crval1 = 0.5*(region[0].Rmin + region[0].Rmax);
@@ -117,17 +116,18 @@
     /* negative dX: j is too large */
     dX = X1[i] - X2[j];
-    if (dX <= -2*RADIUS) {
+    if (dX <= -1.02*RADIUS) {
       i++;
       continue;
     }
     /* positive dX, i is too large */
-    if (dX >= 2*RADIUS) {
+    if (dX >= 1.02*RADIUS) {
       j++;
       continue;
     }
 
+    /* within match range; look for matches */
     Jmin = -1;
     Rmin = RADIUS2;
-    for (J = j; (dX > -2*RADIUS) && (J < Nave); J++) {
+    for (J = j; (dX > -1.02*RADIUS) && (J < Nave); J++) {
       /* find closest match for this detection */
       dX = X1[i] - X2[J];
@@ -195,5 +195,4 @@
     }
 
-
     /* adds the measurement to the calibration if appropriate color terms are found */
     /* we call this before (optionally) setting the average magnitude to avoid auto-correlations */
@@ -285,6 +284,6 @@
 
     // the following measure elements cannot be set until here:
-    catalog[0].measure[Nmeas].dR       = 0.0;
-    catalog[0].measure[Nmeas].dD       = 0.0;
+    catalog[0].measure[Nmeas].dR       = 0.0; // astrometric offset, not error
+    catalog[0].measure[Nmeas].dD       = 0.0; // astrometric offset, not error
     catalog[0].measure[Nmeas].dbFlags  = 0;
     catalog[0].measure[Nmeas].averef   = Nave;
@@ -336,7 +335,9 @@
   free (Y1);
   free (N1);
+  free (N2);
   free (X2);
   free (Y2);
-  free (N2);
+  free (next_meas);
+
   return (Nmatch);
 }
