Index: trunk/Ohana/src/opihi/dvo/calextract.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/calextract.c	(revision 12332)
+++ trunk/Ohana/src/opihi/dvo/calextract.c	(revision 14401)
@@ -7,5 +7,4 @@
   int i, j, m, N, Nr, mode[2];
   int Nsecfilt, NSTAR;
-  char *RegionName, *RegionList;
   double M1, M2, dM2, color;
 
@@ -14,4 +13,5 @@
   Vector **vec;
   SkyList *skylist;
+  SkyRegionSelection *selection;
 
   /* these need to be freed in the end */
@@ -19,7 +19,6 @@
   catalog.secfilt = NULL;
   catalog.measure = NULL;
-  RegionName = NULL;
-  RegionList = NULL;
   skylist = NULL;
+  selection = NULL;
   vec = NULL;
 
@@ -30,5 +29,7 @@
   /* command line arguments */
   SetSelectionParam (0);
-  if (!SetRegionSelection (&argc, argv, &RegionName, &RegionList)) goto escape;
+
+  // parse skyregion options
+  if ((selection = SetRegionSelection (&argc, argv)) == NULL) goto escape;
   if (!SetPhotSelections (&argc, argv, 2)) goto usage;
 
@@ -50,5 +51,5 @@
   if ((vec[Np] 	= SelectVector ("cal:nphot",    ANYVECTOR, TRUE)) == NULL) goto escape;
   if ((vec[Nc] 	= SelectVector ("cal:ncode",    ANYVECTOR, TRUE)) == NULL) goto escape;
-  if ((vec[Nt] 	= SelectVector ("cal:ncrit",    ANYVECTOR, TRUE)) == NULL) goto escape;
+  // if ((vec[Nt] 	= SelectVector ("cal:ncrit",    ANYVECTOR, TRUE)) == NULL) goto escape;
   if ((vec[Nx] 	= SelectVector ("cal:chisq",    ANYVECTOR, TRUE)) == NULL) goto escape;
   if ((vec[Nd1] = SelectVector ("cal:dm1",      ANYVECTOR, TRUE)) == NULL) goto escape;
@@ -56,5 +57,5 @@
 
   /* load region corresponding to selection above */
-  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
+  if ((skylist = SelectRegions (selection)) == NULL) goto escape;
 
   for (Nr = 0; Nr < skylist[0].Nregions; Nr++) {
@@ -73,4 +74,5 @@
     dvo_catalog_unlock (&catalog);
 
+    # if (0)
     /* extract values, assign to vectors */
     for (i = 0; i < catalog.Naverage; i++) {
@@ -104,5 +106,5 @@
       vec[Nc ][0].elements[N] = ExtractAverages (code[0], mode[0], &catalog.average[i], &catalog.secfilt[i*Nsecfilt], &catalog.measure[m], AVE_NCODE);
       vec[Np ][0].elements[N] = ExtractAverages (code[0], mode[0], &catalog.average[i], &catalog.secfilt[i*Nsecfilt], &catalog.measure[m], AVE_NPHOT);
-      vec[Nt ][0].elements[N] = ExtractAverages (code[0], mode[0], &catalog.average[i], &catalog.secfilt[i*Nsecfilt], &catalog.measure[m], AVE_NCRIT);
+      // vec[Nt ][0].elements[N] = ExtractAverages (code[0], mode[0], &catalog.average[i], &catalog.secfilt[i*Nsecfilt], &catalog.measure[m], AVE_NCRIT);
       N ++;
       if (N == NSTAR) {
@@ -113,11 +115,14 @@
       }
     }
+    # endif
     dvo_catalog_free (&catalog);
   }
 
-  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   for (i = 0; i < NVEC; i++) {
     vec[i][0].Nelements = N;
   }
+
+  SkyListFree (skylist);
+  FreeSkyRegionSelection (selection);
   return (TRUE);
   
@@ -127,7 +132,6 @@
 
 escape:
-  if (RegionName != NULL) free (RegionName);
-  if (RegionList != NULL) free (RegionList);
-  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
+  SkyListFree (skylist);
+  FreeSkyRegionSelection (selection);
   for (i = 0; i < NVEC; i++) {
     DeleteVector (vec[i]);
