Index: /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadData.c
===================================================================
--- /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadData.c	(revision 38532)
+++ /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadData.c	(revision 38533)
@@ -10,6 +10,10 @@
 
   Catalog *catalog = NULL;
-  // ALLOCATE (catalog, Catalog, 1);
-  // dvo_catalog_init (catalog, TRUE);
+  ALLOCATE (catalog, Catalog, 1);
+  dvo_catalog_init (catalog, TRUE);
+  ALLOCATE (catalog->average, Average, 1);
+  ALLOCATE (catalog->secfilt, SecFilt, 1);
+  ALLOCATE (catalog->measure, Measure, 1);
+  ALLOCATE (catalog->lensing, Lensing, 1);
 
   if (images[0] == NULL) {
@@ -103,10 +107,22 @@
     // replace full input catalog newcat with subset version
     newcat = FilterStars (newcat, &images[0][Nvalid], Nvalid, options);
-    catalog = newcat;
 
-    // XXX I need to use find_matches_closest here, but for testing:
-    // find_matches_closest (region, catalog, newcat, options);
-    // dvo_catalog_free (newcat);
-    // free (newcat);
+    double Rref, Dref;
+    XY_to_RD (&Rref, &Dref, 0.0, 0.0, &images[0][Nvalid].coords);
+    SkyRegion region;
+    region.Rmin = Rref - 180.0;
+    region.Rmax = Rref + 180.0;
+    region.Dmin = Dref -  90.0;
+    region.Dmax = Dref +  90.0;
+    
+    AddstarClientOptions matchOptions = *options;
+    matchOptions.radius = 0.1; // tight radius at this stage
+    matchOptions.calibrate = FALSE;
+    matchOptions.only_match = FALSE;
+    matchOptions.nosort = FALSE;
+
+    find_matches_closest (&region, newcat, catalog, matchOptions);
+    dvo_catalog_free (newcat);
+    free (newcat);
 
     Nvalid++;
Index: /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/find_matches_closest.c
===================================================================
--- /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/find_matches_closest.c	(revision 38532)
+++ /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/find_matches_closest.c	(revision 38533)
@@ -270,4 +270,5 @@
   /* these new entries are all written out in UPDATE mode */ 
   for (i = 0; (i < Nstars) && !options.only_match; i += NSTAR_GROUP) {
+    fprintf (stderr, "loop %d\n", (int) i);
     /* make sure there is space for next entry */
     if (Nmeas >= NMEAS - NSTAR_GROUP) {
@@ -299,4 +300,6 @@
     catalog[0].average[Nave].catID     	   = catID;
 
+    ohana_memcheck(1);
+
     if (PSPS_ID) {
         catalog[0].average[Nave].extID = CreatePSPSObjectID(catalog[0].average[Nave].R, catalog[0].average[Nave].D);
@@ -306,6 +309,9 @@
 
     for (j = 0; j < Nsecfilt; j++) {
+      // XXXX inconsistent with my alloc above
       dvo_secfilt_init (&catalog[0].secfilt[Nave*Nsecfilt+j], SECFILT_RESET_ALL);
     }
+
+    ohana_memcheck(1);
 
     for (j = 0; j < NSTAR_GROUP; j++) {
@@ -335,4 +341,6 @@
       next_meas[Nmeas - NSTAR_GROUP + j] = Nmeas - NSTAR_GROUP + j + 1;
     }
+
+    ohana_memcheck(1);
 
     // if we have lensing data, insert that as well
@@ -357,4 +365,5 @@
       }
     }
+    ohana_memcheck(1);
 
     Nave ++;
