Index: trunk/Ohana/src/opihi/dvo/ImageSelection.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/ImageSelection.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/ImageSelection.c	(revision 5451)
@@ -9,9 +9,9 @@
 
 /* load images based on parameters and region, etc */
-int SetImageSelection (int mode) {
+int SetImageSelection (int mode, int RegionSelect) {
 
   int Ngraph;
   Graphdata graphsky;
-  int RegionSelect, TimeSelect;
+  int TimeSelect;
   time_t tzero, tend;
 
@@ -19,5 +19,4 @@
   subset = NULL;
   
-  RegionSelect = GetRegionSelection();
   if (RegionSelect) {
     Ngraph = 0;
Index: trunk/Ohana/src/opihi/dvo/Makefile
===================================================================
--- trunk/Ohana/src/opihi/dvo/Makefile	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/Makefile	(revision 5451)
@@ -29,8 +29,5 @@
 $(SDIR)/LoadImages.$(ARCH).o		\
 $(SDIR)/cmpRead.$(ARCH).o		\
-$(SDIR)/aregion.$(ARCH).o               \
 $(SDIR)/compare.$(ARCH).o               \
-$(SDIR)/find_regions.$(ARCH).o	  	\
-$(SDIR)/get_regions.$(ARCH).o           \
 $(SDIR)/match_image.$(ARCH).o		\
 $(SDIR)/photometry.$(ARCH).o            \
@@ -39,4 +36,8 @@
 $(SDIR)/dvo.$(ARCH).o
 
+# $(SDIR)/aregion.$(ARCH).o               \
+# $(SDIR)/find_regions.$(ARCH).o	  	\
+# $(SDIR)/get_regions.$(ARCH).o           \
+
 cmds = \
 $(SDIR)/avextract.$(ARCH).o	  	\
@@ -44,5 +45,4 @@
 $(SDIR)/calextract.$(ARCH).o      	\
 $(SDIR)/calmextract.$(ARCH).o     	\
-$(SDIR)/catalog.$(ARCH).o	  	\
 $(SDIR)/ccd.$(ARCH).o             	\
 $(SDIR)/cmatch.$(ARCH).o	  	\
@@ -75,5 +75,4 @@
 $(SDIR)/lightcurve.$(ARCH).o	  	\
 $(SDIR)/mextract.$(ARCH).o	  	\
-$(SDIR)/pcat.$(ARCH).o		  	\
 $(SDIR)/photcodes.$(ARCH).o	  	\
 $(SDIR)/pmeasure.$(ARCH).o	  	\
@@ -101,4 +100,6 @@
 help: cmd.basic.help cmd.data.help cmd.astro.help dvo.help
 
+$(funcs) $(cmds) $(libs) : $(INC)/dvo1.h
+
 .PHONY: dvo
 
@@ -106,4 +107,5 @@
 
 # deprecated functions: verify & delete
+#$(SDIR)/catalog.$(ARCH).o	  	\
 #$(SDIR)/abszero.$(ARCH).o \
 #$(SDIR)/cals.$(ARCH).o \
@@ -119,4 +121,5 @@
 #$(SDIR)/dmagextract.$(ARCH).o \
 #$(SDIR)/ddmagextract.$(ARCH).o \
+#$(SDIR)/pcat.$(ARCH).o		  	\
 
 # future functions, not fully implemented
Index: trunk/Ohana/src/opihi/dvo/avextract.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/avextract.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/avextract.c	(revision 5451)
@@ -4,14 +4,13 @@
   
   int i, j, m, N, NPTS, param;
-  int Nsec, Nregions, mode;
-  char filename[256], catdir[256], *RegionName, *RegionList, *p;
+  int Nsec, mode;
+  char *RegionName, *RegionList, *p;
 
   Catalog catalog;
-  RegionFile *regions;
+  SkyList *skylist;
   PhotCode *code;
   Vector *vec;
 
   /* defaults */
-  regions = NULL;
   catalog.average = NULL; 
   catalog.secfilt = NULL;
@@ -25,7 +24,4 @@
   if (!InitPhotcodes ()) goto escape;
   Nsec = GetPhotcodeNsecfilt ();
-
-  /* find CATDIR in config system */
-  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
 
   /* interpret command-line options */
@@ -50,5 +46,5 @@
 
   /* load region corresponding to selection above */
-  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
+  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
 
   /* create storage vector */
@@ -57,8 +53,7 @@
   if ((vec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto escape;
 
-  for (i = 0; i < Nregions; i++) {
+  for (i = 0; i < skylist[0].Nregions; i++) {
     /* lock, load, unlock catalog */
-    sprintf (filename, "%s/%s", catdir, regions[i].name);
-    catalog.filename = filename;
+    catalog.filename = (char *) skylist[0].regions[i][0].filename;
     switch (lock_catalog (&catalog, LCK_SOFT)) {
     case 2:
@@ -90,5 +85,5 @@
   REALLOCATE (vec[0].elements, float, MAX(1,N));
 
-  if (regions != NULL) free (regions);
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   return (TRUE);
 
@@ -98,5 +93,5 @@
 
 escape:
-  if (regions != NULL) free (regions);
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   if (catalog.average != NULL) free (catalog.average);
   if (catalog.secfilt != NULL) free (catalog.secfilt);
Index: trunk/Ohana/src/opihi/dvo/calextract.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/calextract.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/calextract.c	(revision 5451)
@@ -5,16 +5,15 @@
 int calextract (int argc, char **argv) {
   
-  int i, j, m, N, Nr, Nregions, mode[2];
+  int i, j, m, N, Nr, mode[2];
   int Nsec, NSTAR;
-  char filename[256], catdir[256], *RegionName, *RegionList;
+  char *RegionName, *RegionList;
   double M1, M2, dM2, color;
 
+  PhotCode *code[2];
   Catalog catalog;
-  RegionFile *regions;
-  PhotCode *code[2];
+  SkyList *skylist;
   Vector **vec;
 
   /* these need to be freed in the end */
-  regions = NULL;
   catalog.average = NULL; 
   catalog.secfilt = NULL;
@@ -27,7 +26,4 @@
   if (!InitPhotcodes ()) return (FALSE);
   Nsec = GetPhotcodeNsecfilt ();
-
-  /* find CATDIR in config system */
-  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
 
   /* command line arguments */
@@ -59,12 +55,11 @@
 
   /* load region corresponding to selection above */
-  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
+  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
 
-  for (Nr = 0; Nr < Nregions; Nr++) {
+  for (Nr = 0; Nr < skylist[0].Nregions; Nr++) {
     if (Nr && !(Nr % 500)) { fprintf (stderr, "."); }
 
     /* lock, load, unlock catalog */
-    sprintf (filename, "%s/%s", catdir, regions[Nr].name);
-    catalog.filename = filename;
+    catalog.filename = (char *) skylist[0].regions[Nr][0].filename;
     switch (lock_catalog (&catalog, LCK_SOFT)) {
     case 2:
@@ -127,5 +122,6 @@
     catalog.measure = (Measure *) NULL;
   }
-  if (regions != NULL) free (regions);  
+
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   for (i = 0; i < NVEC; i++) {
     vec[i][0].Nelements = N;
@@ -141,5 +137,5 @@
   if (RegionName != NULL) free (RegionName);
   if (RegionList != NULL) free (RegionList);
-  if (regions != NULL) free (regions);  
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   for (i = 0; i < NVEC; i++) {
     DeleteVector (vec[i]);
Index: trunk/Ohana/src/opihi/dvo/calmextract.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/calmextract.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/calmextract.c	(revision 5451)
@@ -7,15 +7,14 @@
   
   int i, j, k, m, N, N1, Nr, mode[2];
-  int NSTAR, Nstar, Nsec, Nregions;
-  char filename[256], catdir[256], *RegionName, *RegionList;
+  int NSTAR, Nstar, Nsec;
+  char *RegionName, *RegionList;
   double *M1, M2, dM2, color;
 
   Catalog catalog;
-  RegionFile *regions;
   PhotCode *code[2];
+  SkyList *skylist;
   Vector **vec;
 
   /* these need to be freed in the end */
-  regions = NULL;
   catalog.average = NULL; 
   catalog.secfilt = NULL;
@@ -28,7 +27,4 @@
   if (!InitPhotcodes ()) goto escape;
   Nsec = GetPhotcodeNsecfilt ();
-
-  /* find CATDIR in config system */
-  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
 
   /* command line arguments */
@@ -71,13 +67,12 @@
 
   /* load region corresponding to selection above */
-  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
-  if (!SetImageSelection (MEAS_XMOSAIC)) goto escape;
+  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
+  if (!SetImageSelection (MEAS_XMOSAIC, ((RegionName == NULL) && (RegionList == NULL)))) goto escape;
 
-  for (Nr = 0; Nr < Nregions; Nr++) {
+  for (Nr = 0; Nr < skylist[0].Nregions; Nr++) {
     if (Nr && !(Nr % 500)) { fprintf (stderr, "."); }
 
     /* lock, load, unlock catalog */
-    sprintf (filename, "%s/%s", catdir, regions[Nr].name);
-    catalog.filename = filename;
+    catalog.filename = (char *) skylist[0].regions[Nr][0].filename;
     switch (lock_catalog (&catalog, LCK_SOFT)) {
     case 2:
@@ -153,5 +148,6 @@
     catalog.measure = (Measure *) NULL;
   }
-  if (regions != NULL) free (regions);  
+
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   for (i = 0; i < NVEC; i++) {
     vec[i][0].Nelements = N;
@@ -167,5 +163,5 @@
   
   FreeImageSelection ();
-  if (regions != NULL) free (regions);  
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   for (i = 0; i < NVEC; i++) {
     DeleteVector (vec[i]);
Index: trunk/Ohana/src/opihi/dvo/catdir.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/catdir.c	(revision 5451)
+++ trunk/Ohana/src/opihi/dvo/catdir.c	(revision 5451)
@@ -0,0 +1,31 @@
+# include "dvo1.h"
+
+int catdir_define (int argc, char **argv) {
+  
+  int VERBOSE;
+
+  VERBOSE = FALSE;
+  if ((N = get_argument (argc, argv, "-v"))) {
+    VERBOSE = TRUE;
+    remove_argument (N, &argc, argv);
+  }
+
+  if (argc != 2) {
+    fprintf (stderr, "USAGE: catdir (name)\n");
+    fprintf (stderr, "       (name) may be a path or 'default'\n");
+    return (FALSE);
+  }
+
+  if (!strcasecmp (argv[1], "default")) {
+    status = SetCATDIR (NULL, VERBOSE);
+  } else {
+    status = SetCATDIR (argv[1], VERBOSE);
+  }
+
+  if (!status) {
+    fprintf (stderr, "invalid / undefined CATDIR\n");
+    return (FALSE);
+  }
+
+  return (TRUE);
+}
Index: trunk/Ohana/src/opihi/dvo/ccd.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/ccd.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/ccd.c	(revision 5451)
@@ -3,17 +3,16 @@
 int ccd (int argc, char **argv) {
   
-  char filename[256], catdir[256], *RegionName, *RegionList;
+  char *RegionName, *RegionList;
   double *M1, *M2;
   int i, m, k, Npts, NPTS, N;
   int N1, N2, i1, i2, mode[4];
-  int Nsec, Nregions, KeepNulls;
+  int Nsec, KeepNulls;
 
   Catalog catalog;
-  RegionFile *regions;
   PhotCode *code[4];
+  SkyList *skylist;
   Vector *xvec, *yvec;
 
   /* defaults */
-  regions = NULL;
   catalog.average = NULL; 
   catalog.secfilt = NULL;
@@ -25,7 +24,4 @@
   if (!InitPhotcodes ()) goto escape;
   Nsec = GetPhotcodeNsecfilt ();
-
-  /* find CATDIR in config system */
-  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
 
   /* interpret command-line options */
@@ -51,5 +47,5 @@
 
   /* load region corresponding to selection above */
-  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
+  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
 
   /* init vectors to save data */
@@ -60,8 +56,7 @@
 
   /* loop over regions, extract data for each region */
-  for (k = 0; k < Nregions; k++) {
+  for (k = 0; k < skylist[0].Nregions; k++) {
     /* lock, load, unlock catalog */
-    sprintf (filename, "%s/%s", catdir, regions[k].name);
-    catalog.filename = filename;
+    catalog.filename = (char *) skylist[0].regions[k][0].filename;
     switch (lock_catalog (&catalog, LCK_SOFT)) {
       case 2:
@@ -121,5 +116,5 @@
     catalog.measure = (Measure *) NULL;
   }
-  if (regions != NULL) free (regions);
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   xvec[0].Nelements = yvec[0].Nelements = Npts;
   return (TRUE);
@@ -130,5 +125,5 @@
 
 escape:
-  if (regions != NULL) free (regions);
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   if (catalog.average != NULL) free (catalog.average);
   if (catalog.secfilt != NULL) free (catalog.secfilt);
Index: trunk/Ohana/src/opihi/dvo/cmatch.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/cmatch.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/cmatch.c	(revision 5451)
@@ -6,10 +6,6 @@
   char filename[128];
   double radius;
-  char catdir[256], gscdir[256];
   Vector *rvec, *dvec, *mvec, *drvec, *ddvec, *dmvec;
 
-  VarConfig ("GSCDIR", "%s", gscdir);
-  VarConfig ("CATDIR", "%s", catdir);
-      
   if (argc != 9) {
     fprintf (stderr, "USAGE: cmatch file radius (RA) (DEC) (Mag) (dRA) (dDEC) (dMag)\n");
@@ -32,5 +28,4 @@
 
   /* load data from the photometry database file */
-  sprintf (filename, "%s/%s", catdir, argv[1]);
   catalog1.filename = filename;
   switch (lock_catalog (&catalog1, LCK_SOFT)) {
Index: trunk/Ohana/src/opihi/dvo/cmd.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/cmd.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/cmd.c	(revision 5451)
@@ -3,17 +3,16 @@
 int cmd (int argc, char **argv) { /* really need to think about upper limits & how to represent them */
   
-  char filename[256], catdir[256], *RegionName, *RegionList;
+  char *RegionName, *RegionList;
   double *M1, *M3;
   int i, j, m, i1, i3, N1, N3, N;
   int Npts, NPTS, mode[3];
-  int Nsec, Nregions, KeepNulls;
+  int Nsec, KeepNulls;
 
+  PhotCode *code[3];
   Catalog catalog;
-  RegionFile *regions;
-  PhotCode *code[3];
+  SkyList *skylist;
   Vector *xvec, *yvec;
 
   /* defaults */
-  regions = NULL;
   catalog.average = NULL; 
   catalog.secfilt = NULL;
@@ -25,7 +24,4 @@
   if (!InitPhotcodes ()) goto escape;
   Nsec = GetPhotcodeNsecfilt ();
-
-  /* find CATDIR in config system */
-  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
 
   /* interpret command-line options */
@@ -49,5 +45,5 @@
 
   /* load region corresponding to selection above */
-  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
+  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
 
   /* init vectors to save data */
@@ -58,8 +54,7 @@
 
   /* loop over regions, extract data for each region */
-  for (j = 0; j < Nregions; j++) {
+  for (j = 0; j < skylist[0].Nregions; j++) {
     /* lock, load, unlock catalog */
-    sprintf (filename, "%s/%s", catdir, regions[j].name);
-    catalog.filename = filename;
+    catalog.filename = (char *) skylist[0].regions[j][0].filename;
     switch (lock_catalog (&catalog, LCK_SOFT)) {
     case 2:
@@ -119,5 +114,5 @@
     catalog.measure = (Measure *) NULL;
   }
-  if (regions != NULL) free (regions);
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   xvec[0].Nelements = yvec[0].Nelements = Npts;
   return (TRUE);
@@ -128,5 +123,5 @@
 
 escape:
-  if (regions != NULL) free (regions);
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   if (catalog.average != NULL) free (catalog.average);
   if (catalog.secfilt != NULL) free (catalog.secfilt);
Index: trunk/Ohana/src/opihi/dvo/ddmags.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/ddmags.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/ddmags.c	(revision 5451)
@@ -3,17 +3,16 @@
 int ddmags (int argc, char **argv) {
   
-  char filename[256], catdir[256], *RegionName, *RegionList;
+  char *RegionName, *RegionList;
   double *M1, *M2;
   int i, m, k, N, Npts, NPTS;
   int N1, N2, i1, i2, mode[4];
-  int Nsec, Nregions, KeepNulls;
+  int Nsec, KeepNulls;
 
   Catalog catalog;
-  RegionFile *regions;
   PhotCode *code[4];
+  SkyList *skylist;
   Vector *xvec, *yvec;
 
   /* defaults */
-  regions = NULL;
   catalog.average = NULL; 
   catalog.secfilt = NULL;
@@ -25,7 +24,4 @@
   if (!InitPhotcodes ()) goto escape;
   Nsec = GetPhotcodeNsecfilt ();
-
-  /* find CATDIR in config system */
-  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
 
   /* interpret command-line options */
@@ -51,5 +47,5 @@
 
   /* load region corresponding to selection above */
-  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
+  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
 
   /* init vectors to save data */
@@ -60,8 +56,7 @@
 
   /* loop over regions, extract data for each region */
-  for (k = 0; k < Nregions; k++) {
+  for (k = 0; k < skylist[0].Nregions; k++) {
     /* lock, load, unlock catalog */
-    sprintf (filename, "%s/%s", catdir, regions[k].name);
-    catalog.filename = filename;
+    catalog.filename = (char *) skylist[0].regions[k][0].filename;
     switch (lock_catalog (&catalog, LCK_SOFT)) {
       case 2:
@@ -121,5 +116,5 @@
     catalog.measure = (Measure *) NULL;
   }
-  if (regions != NULL) free (regions);
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   xvec[0].Nelements = yvec[0].Nelements = Npts;
   return (TRUE);
@@ -129,5 +124,5 @@
 
 escape:
-  if (regions != NULL) free (regions);
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   if (catalog.average != NULL) free (catalog.average);
   if (catalog.secfilt != NULL) free (catalog.secfilt);
Index: trunk/Ohana/src/opihi/dvo/dmagaves.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/dmagaves.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/dmagaves.c	(revision 5451)
@@ -3,17 +3,16 @@
 int dmagaves (int argc, char **argv) {
   
-  char filename[256], catdir[256], *RegionName, *RegionList;
+  char *RegionName, *RegionList;
   double *M1, M2;
   int i, j, k, m, N1;
   int Npts, NPTS, param, mode[3];
-  int Nsec, Nregions;
+  int Nsec;
 
+  PhotCode *code[3];
   Catalog catalog;
-  RegionFile *regions;
-  PhotCode *code[3];
+  SkyList *skylist;
   Vector *xvec, *yvec;
 
   /* defaults */
-  regions = NULL;
   catalog.average = NULL; 
   catalog.secfilt = NULL;
@@ -26,7 +25,4 @@
   if (!InitPhotcodes ()) goto escape;
   Nsec = GetPhotcodeNsecfilt ();
-
-  /* find CATDIR in config system */
-  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
 
   /* interpret command-line options */
@@ -44,5 +40,5 @@
 
   /* load region corresponding to selection above */
-  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
+  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
 
   /* init vectors to save data */
@@ -52,8 +48,7 @@
   if ((yvec = SelectVector ("yv", ANYVECTOR, TRUE)) == NULL) goto escape;
 
-  for (j = 0; j < Nregions; j++) {
+  for (j = 0; j < skylist[0].Nregions; j++) {
     /* lock, load, unlock catalog */
-    sprintf (filename, "%s/%s", catdir, regions[j].name);
-    catalog.filename = filename;
+    catalog.filename = (char *) skylist[0].regions[j][0].filename;
     switch (lock_catalog (&catalog, LCK_SOFT)) {
     case 2:
@@ -101,5 +96,5 @@
     catalog.measure = (Measure *) NULL;
   }
-  if (regions != NULL) free (regions);
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   xvec[0].Nelements = yvec[0].Nelements = Npts;
   return (TRUE);
@@ -110,5 +105,5 @@
 
 escape:
-  if (regions != NULL) free (regions);
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   if (catalog.average != NULL) free (catalog.average);
   if (catalog.secfilt != NULL) free (catalog.secfilt);
Index: trunk/Ohana/src/opihi/dvo/dmagmeas.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/dmagmeas.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/dmagmeas.c	(revision 5451)
@@ -3,17 +3,16 @@
 int dmagmeas (int argc, char **argv) {
   
-  char filename[256], catdir[256], *RegionName, *RegionList;
+  char *RegionName, *RegionList;
   double *M1, *M3;
   int i, j, m, i1, i3, N1, N3, N;
   int Npts, NPTS, param, mode[3];
-  int Nsec, Nregions, KeepNulls;
+  int Nsec, KeepNulls;
 
   Catalog catalog;
-  RegionFile *regions;
   PhotCode *code[3];
+  SkyList *skylist;
   Vector *xvec, *yvec;
 
   /* defaults */
-  regions = NULL;
   catalog.average = NULL; 
   catalog.secfilt = NULL;
@@ -26,7 +25,4 @@
   if (!InitPhotcodes ()) goto escape;
   Nsec = GetPhotcodeNsecfilt ();
-
-  /* find CATDIR in config system */
-  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
 
   /* interpret command-line options */
@@ -50,6 +46,6 @@
 
   /* load region corresponding to selection above */
-  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
-  if (!SetImageSelection (param)) goto escape;
+  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
+  if (!SetImageSelection (param, ((RegionName == NULL) && (RegionList == NULL)))) goto escape;
 
   /* init vectors to save data */
@@ -60,8 +56,7 @@
 
   /* loop over regions, extract data for each region */
-  for (j = 0; j < Nregions; j++) {
+  for (j = 0; j < skylist[0].Nregions; j++) {
     /* lock, load, unlock catalog */
-    sprintf (filename, "%s/%s", catdir, regions[j].name);
-    catalog.filename = filename;
+    catalog.filename = (char *) skylist[0].regions[j][0].filename;
     switch (lock_catalog (&catalog, LCK_SOFT)) {
       case 2:
@@ -122,5 +117,5 @@
   }
   FreeImageSelection ();
-  if (regions != NULL) free (regions);
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   xvec[0].Nelements = yvec[0].Nelements = Npts;
   return (TRUE);
@@ -132,5 +127,5 @@
 escape:
   FreeImageSelection ();
-  if (regions != NULL) free (regions);
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   if (catalog.average != NULL) free (catalog.average);
   if (catalog.secfilt != NULL) free (catalog.secfilt);
Index: trunk/Ohana/src/opihi/dvo/dmags.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/dmags.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/dmags.c	(revision 5451)
@@ -3,17 +3,16 @@
 int dmags (int argc, char **argv) {
   
-  char filename[256], catdir[256], *RegionName, *RegionList;
+  char *RegionName, *RegionList;
   double *M1, *M3;
   int i, j, m, i1, i3, N1, N3, N;
   int Npts, NPTS, mode[3];
-  int Nsec, Nregions, KeepNulls;
+  int Nsec, KeepNulls;
 
   PhotCode *code[3];
   Catalog catalog;
-  RegionFile *regions;
+  SkyList *skylist;
   Vector *xvec, *yvec;
 
   /* defaults */
-  regions = NULL;
   catalog.average = NULL; 
   catalog.secfilt = NULL;
@@ -25,7 +24,4 @@
   if (!InitPhotcodes ()) goto escape;
   Nsec = GetPhotcodeNsecfilt ();
-
-  /* find CATDIR in config system */
-  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
 
   /* interpret command-line options */
@@ -49,5 +45,5 @@
 
   /* load region corresponding to selection above */
-  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
+  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
 
   /* init vectors to save data */
@@ -58,8 +54,7 @@
 
   /* loop over regions, extract data for each region */
-  for (j = 0; j < Nregions; j++) {
+  for (j = 0; j < skylist[0].Nregions; j++) {
     /* lock, load, unlock catalog */
-    sprintf (filename, "%s/%s", catdir, regions[j].name);
-    catalog.filename = filename;
+    catalog.filename = (char *) skylist[0].regions[j][0].filename;
     switch (lock_catalog (&catalog, LCK_SOFT)) {
       case 2:
@@ -119,5 +114,7 @@
     catalog.measure = (Measure *) NULL;
   }
-  if (regions != NULL) free (regions);
+
+  /* need to free SkyList / or free all regions as well */
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   xvec[0].Nelements = yvec[0].Nelements = Npts;
   return (TRUE);
@@ -132,5 +129,5 @@
 
 escape:
-  if (regions != NULL) free (regions);
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   if (catalog.average != NULL) free (catalog.average);
   if (catalog.secfilt != NULL) free (catalog.secfilt);
Index: trunk/Ohana/src/opihi/dvo/dmt.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/dmt.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/dmt.c	(revision 5451)
@@ -6,5 +6,4 @@
   int i, m, k, N, Ngraph, SaveVectors;
   int Ns, Nsec, NPTS;
-  char catdir[256], filename[256];
   double Radius;
   float dt1, dt2, dmt1, dmt2;
@@ -19,6 +18,4 @@
 
   if (!InitPhotcodes ()) return (FALSE);
-
-  VarConfig ("CATDIR", "%s", catdir);
 
   vec1 = vec2 = vec3 = vec4 = vec5 = NULL;
@@ -54,9 +51,7 @@
   Ns = GetPhotcodeNsec (code[0].code);
 
-  /* load sky from correct table */
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
-  SkyTableSetFilenames (sky, CATDIR, "cpt");
+  Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
 
-  Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
+  sky = GetSkyTable ();
   skylist = SkyListByRadius (sky, -1, graphsky.coords.crval1, graphsky.coords.crval2, Radius);
   
@@ -74,5 +69,5 @@
 
     /* lock, load, unlock catalog */
-    catalog.filename = skylist[0].regions[k][0].filename;
+    catalog.filename = (char *) skylist[0].regions[k][0].filename;
     switch (lock_catalog (&catalog, LCK_SOFT)) {
     case 2:
Index: trunk/Ohana/src/opihi/dvo/dvo.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/dvo.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/dvo.c	(revision 5451)
@@ -17,4 +17,8 @@
   InitAstro ();
   InitDVO ();
+
+  if (SetCATDIR (NULL, TRUE)) {
+    fprintf (stderr, "CATDIR is not defined\n");
+  }
 
   rl_readline_name = opihi_name;
Index: trunk/Ohana/src/opihi/dvo/fitcolors.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/fitcolors.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/fitcolors.c	(revision 5451)
@@ -13,6 +13,6 @@
   int i, k, m, NP1, NP2, NP, Np, Npts, NPTS;
   int N1, N2, i1, i2, mode[4];
-  int Nsec, Nregions, status;
-  char catdir[256], filename[256], *RegionName, *RegionList;
+  int Nsec, status;
+  char *RegionName, *RegionList;
   char *cmd, *outcmd, *camera;
   double *M1, *M2;
@@ -20,11 +20,10 @@
 
   Catalog *catalog;
-  RegionFile *regions;
   PhotCode **codelist, *tcode, *code[4];
+  SkyList *skylist;
   Vector *xvec, *yvec;
   Buffer *buf;
 
   /* defaults */
-  regions  = NULL;
   catalog  = NULL;
   codelist = NULL;
@@ -34,7 +33,4 @@
   if (!InitPhotcodes ()) goto escape;
   Nsec = GetPhotcodeNsecfilt ();
-
-  /* find CATDIR in config system */
-  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
 
   /* interpret command-line options */
@@ -97,12 +93,11 @@
 
   /* load region corresponding to selection above */
-  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
+  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
 
   /* loop over regions, extract data for each region */
-  ALLOCATE (catalog, Catalog, Nregions);
-  for (k = 0; k < Nregions; k++) {
+  ALLOCATE (catalog, Catalog, skylist[0].Nregions);
+  for (k = 0; k < skylist[0].Nregions; k++) {
     /* lock, load, unlock catalog */
-    sprintf (filename, "%s/%s", catdir, regions[k].name);
-    catalog[k].filename = filename;
+    catalog[k].filename = (char *) skylist[0].regions[k][0].filename;
     switch (lock_catalog (&catalog[k], LCK_SOFT)) {
       case 2:
@@ -120,5 +115,5 @@
     unlock_catalog (&catalog[k]);
   }
-  fprintf (stderr, "using %d regions\n", Nregions);
+  fprintf (stderr, "using %d regions\n", skylist[0].Nregions);
 
   /* vectors to save data */
@@ -137,5 +132,5 @@
       /* extract all magnitude pairs from catalog tables */
       Npts = 0;
-      for (k = 0; k < Nregions; k++) {
+      for (k = 0; k < skylist[0].Nregions; k++) {
 	if (catalog[k].Naverage == 0) continue;
 
@@ -186,4 +181,7 @@
     }
   }
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
+  if (RegionName != NULL) free (RegionName);
+  if (RegionList != NULL) free (RegionList);
   return (TRUE);
 
@@ -196,9 +194,11 @@
 
 escape:
-  if (regions != NULL) free (regions);
+  free_catalog (catalog, skylist[0].Nregions);
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
+  if (RegionName != NULL) free (RegionName);
+  if (RegionList != NULL) free (RegionList);
   if (codelist != NULL) free (codelist);
   DeleteVector (xvec);
   DeleteVector (yvec);
-  free_catalog (catalog, Nregions);
   return (FALSE);
 }
Index: trunk/Ohana/src/opihi/dvo/gcat.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/gcat.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/gcat.c	(revision 5451)
@@ -8,7 +8,4 @@
   SkyTable *sky;
   SkyList *skylist;
-  char catdir[256];
-
-  VarConfig ("CATDIR", "%s", catdir);
 
   if ((argc != 3) && (argc != 4)) {
@@ -18,7 +15,4 @@
 
   /* load sky from correct table */
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
-  SkyTableSetFilenames (sky, CATDIR, "cpt");
-
   Ra = atof (argv[1]);
   Dec = atof (argv[2]);
@@ -28,16 +22,17 @@
     Radius = 0.0001;
 
+  sky = GetSkyTable ();
   skylist = SkyListByRadius (sky, -1, Ra, Dec, Radius);
 
   for (i = 0; i < skylist[0].Nregions; i++) {
-    if (stat (skylist[0].regions[i][0].filename, &filestat) != -1) {
-      fprintf (stderr, "%3d %s *\n", i, regions[i].name);
+    if (stat ((char *) skylist[0].regions[i][0].filename, &filestat) != -1) {
+      fprintf (stderr, "%3d %s *\n", i, skylist[0].regions[i][0].name);
     } else {
-      fprintf (stderr, "%3d %s\n", i, regions[i].name);
+      fprintf (stderr, "%3d %s\n", i, skylist[0].regions[i][0].name);
     } 
-    set_str_variable ("CATNAME", regions[i].name);
+    set_str_variable ("CATNAME", (char *) skylist[0].regions[i][0].filename);
   }
 
   return (TRUE);
-  SkyListFree (regions);
+  SkyListFree (skylist, FALSE);
 }
Index: trunk/Ohana/src/opihi/dvo/gstar.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/gstar.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/gstar.c	(revision 5451)
@@ -5,5 +5,5 @@
 int gstar (int argc, char **argv) {
   
-  char filename[128], catdir[256], *date;
+  char *date;
   double Ra, Dec, Radius, Radius2, r, dec0, dec1;
   double Mcat, Mrel;
@@ -18,6 +18,4 @@
   PhotCode *code;
 
-  if (VarConfig ("CATDIR", "%s", catdir) == NULL) return (FALSE);
-
   if (!InitPhotcodes ()) return (FALSE);
   Nsec = GetPhotcodeNsecfilt ();
@@ -54,6 +52,5 @@
   
   /* load sky from correct table */
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
-  SkyTableSetFilenames (sky, CATDIR, "cpt");
+  sky = GetSkyTable ();
   skylist = SkyListByRadius (sky, -1, Ra, Dec, Radius);
 
@@ -63,5 +60,5 @@
 
   /* lock, load, unlock catalog */
-  catalog.filename = skylist[0].regions[0][0].filename;
+  catalog.filename = (char *) skylist[0].regions[0][0].filename;
   switch (lock_catalog (&catalog, LCK_SOFT)) {
   case 2:
Index: trunk/Ohana/src/opihi/dvo/imdata.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/imdata.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/imdata.c	(revision 5451)
@@ -4,8 +4,7 @@
   
   int i, j, k, I;
-  int Nimage, N, NPTS, skip, mode, TimeSelect;
-  int n, Nregion, Ntregion, TimeFormat;
+  int Nimage, N, NPTS, found, mode, TimeSelect;
+  int n, Nregions, NREGIONS, TimeFormat;
   int *subset, Nsubset;
-  char filename[256];
   double trange;
   unsigned long tzero, start, stop, TimeReference;
@@ -81,11 +80,10 @@
 
   /* load sky from correct table */
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
-  SkyTableSetFilenames (sky, CATDIR, "cpt");
+  sky = GetSkyTable ();
 
   Nregions = 0;
   NREGIONS = 10;
   ALLOCATE (skylist, SkyList, 1);
-  ALLOCATE (skylist[0].regions, SkyRegions *, NREGIONS);
+  ALLOCATE (skylist[0].regions, SkyRegion *, NREGIONS);
 
   /* for each image of interest, find the appropriate region files */
@@ -94,17 +92,17 @@
 
     if (!FindMosaicForImage (image, Nimage, I)) continue;
-    skyset = SkyListByImage (table, -1, &image[I]);
+    skyset = SkyListByImage (sky, -1, &image[I]);
 
     for (j = 0; j < skyset[0].Nregions; j++) {
       found = FALSE;
-      for (k = 0; (k < skylist[0].Nregion) && !found; k++) {
-	found = !strcmp (skylist[0].regions[k].name, skyset[0].regions[j].name);
+      for (k = 0; (k < skylist[0].Nregions) && !found; k++) {
+	found = !strcmp (skylist[0].regions[k][0].name, skyset[0].regions[j][0].name);
       }
       if (found) continue;
       skylist[0].regions[Nregions] = skyset[0].regions[j];
       Nregions ++;
-      CHECK_REALLOCATE (skylist[0].regions, SkyRegions *, NREGIONS, Nregions, 10);
-    }
-    SkyListFree (skyset);
+      CHECK_REALLOCATE (skylist[0].regions, SkyRegion *, NREGIONS, Nregions, 10);
+    }
+    SkyListFree (skyset, FALSE);
   }	
   free (subset);
@@ -122,5 +120,5 @@
 
     /* get file name and open */
-    catalog.filename = skylist[0].regions[j][0].filename;
+    catalog.filename = (char *) skylist[0].regions[j][0].filename;
     switch (lock_catalog (&catalog, LCK_SOFT)) {
     case 2:
Index: trunk/Ohana/src/opihi/dvo/init.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/init.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/init.c	(revision 5451)
@@ -112,4 +112,3 @@
     AddCommand (&cmds[i]);
   }
-
 }
Index: trunk/Ohana/src/opihi/dvo/lcat.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/lcat.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/lcat.c	(revision 5451)
@@ -4,8 +4,7 @@
   
   double Radius;
-  int i, N, Nregions, ShowAll;
-  char filename[128], exists;
+  int i, N, ShowAll;
+  char exists;
   struct stat filestat;
-  char catdir[256];
   Graphdata graphmode;
   int Ngraph;
@@ -15,10 +14,4 @@
   Ngraph = 0;
   if (!GetGraphData (&graphmode, NULL, &Ngraph)) return (FALSE);
-
-  VarConfig ("CATDIR", "%s", catdir);
-
-  /* load sky from correct table */
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
-  SkyTableSetFilenames (sky, CATDIR, "cpt");
 
   ShowAll = FALSE;
@@ -33,9 +26,12 @@
 
   Radius = MAX (fabs(graphmode.xmax), fabs(graphmode.ymax));
+
+  /* load sky from correct table */
+  sky = GetSkyTable ();
   skylist = SkyListByRadius (sky, -1, graphmode.coords.crval1, graphmode.coords.crval2, Radius);
 
   for (i = 0; i < skylist[0].Nregions; i++) {
     exists = 'Y';
-    if (stat (skylist[0].regions[i][0].filename, &filestat) == -1) exists = 'N';
+    if (stat ((char *) skylist[0].regions[i][0].filename, &filestat) == -1) exists = 'N';
     if (ShowAll) {
       fprintf (stderr, "%3d %s  %c\n", i, skylist[0].regions[i][0].name, exists);
@@ -47,6 +43,6 @@
   }
 
+  SkyListFree (skylist, FALSE);
   return (TRUE);
-  SkyListFree (regions);
 }
 
Index: trunk/Ohana/src/opihi/dvo/lcurve.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/lcurve.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/lcurve.c	(revision 5451)
@@ -3,5 +3,5 @@
 int lcurve (int argc, char **argv) {
   
-  char filename[128], string[128], catdir[256], *p;
+  char string[128], *p;
   double Ra, Dec, Radius, Radius2, r;
   float *RA, *DEC;
@@ -18,6 +18,4 @@
   SkyList *skylist;
 
-  VarConfig ("CATDIR", "%s", catdir);
-
   if (!InitPhotcodes ()) return (FALSE);
 
@@ -70,12 +68,10 @@
   }
   
-  /* load sky from correct table */
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
-  SkyTableSetFilenames (sky, CATDIR, "cpt");
-
   Ra = atof (argv[1]);
   Dec = atof (argv[2]);
   Radius = atof (argv[3]);
 
+  /* load sky from correct table */
+  sky = GetSkyTable ();
   skylist = SkyListByRadius (sky, -1, Ra, Dec, Radius);
 
@@ -85,5 +81,5 @@
 
   /* set filename, read in header */
-  catalog.filename = skylist[0].regions[0][0].filename;
+  catalog.filename = (char *) skylist[0].regions[0][0].filename;
   switch (lock_catalog (&catalog, LCK_SOFT)) {
   case 2:
@@ -202,5 +198,5 @@
   if (catalog.measure != 0) free (catalog.measure);
  
-  SkyListFree (skylist);
+  SkyListFree (skylist, FALSE);
   return (TRUE);
 }
Index: trunk/Ohana/src/opihi/dvo/lightcurve.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/lightcurve.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/lightcurve.c	(revision 5451)
@@ -3,5 +3,4 @@
 int lightcurve (int argc, char **argv) {
   
-  char filename[128], catdir[256];
   double Ra, Dec, Radius, Radius2, r;
   float *RA, *DEC;
@@ -9,9 +8,10 @@
   int i, j, k, m, N, NPTS, Nsec, RELPHOT, *N1, TimeFormat;
   time_t TimeReference;
+
+  PhotCode *code;
+  Catalog catalog;
+  SkyTable *sky;
+  SkyList *skylist;
   Vector *tvec, *mvec, *dmvec;
-  Catalog catalog;
-  PhotCode *code;
-
-  VarConfig ("CATDIR", "%s", catdir);
 
   if (!InitPhotcodes ()) return (FALSE);
@@ -49,6 +49,5 @@
   Radius = atof (argv[3]);
 
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
-  SkyTableSetFilenames (sky, CATDIR, "cpt");
+  sky = GetSkyTable ();
   skylist = SkyListByRadius (sky, -1, Ra, Dec, Radius);
 
@@ -58,5 +57,5 @@
 
   /* set filename, read in header */
-  catalog.filename = skylist[0].regions[0][0].filename;
+  catalog.filename = (char *) skylist[0].regions[0][0].filename;
   switch (lock_catalog (&catalog, LCK_SOFT)) {
   case 2:
@@ -148,5 +147,5 @@
   if (catalog.secfilt != 0) free (catalog.secfilt);
  
-  SkyListFree (skylist);
+  SkyListFree (skylist, FALSE);
   return (TRUE);
 }
Index: trunk/Ohana/src/opihi/dvo/mextract.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/mextract.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/mextract.c	(revision 5451)
@@ -4,15 +4,14 @@
   
   int i, j, k, m, N, N1, NPTS;
-  int param, mode, Nregions, Nsec;
-  char filename[128], catdir[256], *RegionName, *RegionList, *p;
+  int param, mode, Nsec;
+  char *RegionName, *RegionList, *p;
   double *M1;
 
   PhotCode *code;
   Catalog catalog;
-  RegionFile *regions;
+  SkyList *skylist;
   Vector *vec;
 
   /* defaults */
-  regions = NULL;
   catalog.average = (Average *) NULL; 
   catalog.secfilt = (SecFilt *) NULL;
@@ -26,7 +25,4 @@
   if (!InitPhotcodes ()) goto escape;
   Nsec = GetPhotcodeNsecfilt ();
-
-  /* find CATDIR in config system */
-  if (VarConfig ("CATDIR", "%s", catdir) == NULL) goto escape;
 
   /* interpret command-line options */
@@ -51,6 +47,6 @@
 
   /* load region corresponding to selection above */
-  if ((regions = SelectRegions (RegionName, RegionList, &Nregions)) == NULL) goto escape;
-  if (!SetImageSelection (param)) goto escape;
+  if ((skylist = SelectRegions (RegionName, RegionList)) == NULL) goto escape;
+  if (!SetImageSelection (param, ((RegionName == NULL) && (RegionList == NULL)))) goto escape;
 
   /* create storage vector */
@@ -59,8 +55,6 @@
   if ((vec = SelectVector (argv[1], ANYVECTOR, TRUE)) == NULL) goto escape;
 
-  for (i = 0; i < Nregions; i++) {
-    /* lock, load, unlock catalog */
-    sprintf (filename, "%s/%s", catdir, regions[i].name);
-    catalog.filename = filename;
+  for (i = 0; i < skylist[0].Nregions; i++) {
+    catalog.filename = (char *) skylist[0].regions[i][0].filename;
     switch (lock_catalog (&catalog, LCK_SOFT)) {
     case 2:
@@ -97,6 +91,8 @@
   REALLOCATE (vec[0].elements, float, MAX(1,N));
 
-  if (regions != NULL) free (regions);
   FreeImageSelection ();
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
+  if (RegionName != NULL) free (RegionName);
+  if (RegionList != NULL) free (RegionList);
   return (TRUE);
 
@@ -108,5 +104,5 @@
 escape:
   FreeImageSelection ();
-  if (regions != NULL) free (regions);
+  SkyListFree (skylist, ((RegionName != NULL) || (RegionList != NULL)));
   if (catalog.average != NULL) free (catalog.average);
   if (catalog.secfilt != NULL) free (catalog.secfilt);
Index: trunk/Ohana/src/opihi/dvo/pmeasure.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/pmeasure.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/pmeasure.c	(revision 5451)
@@ -6,5 +6,4 @@
   int i, j, k, m, N;
   int Ngraph;
-  char filename[128], catdir[256];
   double Mz, Mr, mag;
   double Radius, Rmin, Rmax;
@@ -22,5 +21,4 @@
   if (!InitPhotcodes ()) return (FALSE);
   if (!GetGraph (&graphmode, NULL, &Ngraph)) return (FALSE);
-  if (VarConfig ("CATDIR", "%s", catdir) == NULL) return (FALSE);
 
   f = (FILE *) NULL;
@@ -76,6 +74,5 @@
 
   /* load sky from correct table */
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
-  SkyTableSetFilenames (sky, CATDIR, "cpt");
+  sky = GetSkyTable ();
   skylist = SkyListByRadius (sky, -1, graphmode.coords.crval1, graphmode.coords.crval2, Radius);
   
@@ -84,5 +81,5 @@
     
     /* lock, load, unlock catalog */
-    catalog.filename = skylist[0].regions[j][0].filename;
+    catalog.filename = (char *) skylist[0].regions[j][0].filename;
     switch (lock_catalog (&catalog, LCK_SOFT)) {
     case 2:
Index: trunk/Ohana/src/opihi/dvo/region_list.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/region_list.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/region_list.c	(revision 5451)
@@ -5,8 +5,42 @@
    information carried back up */
 
-static int RegionSelect;
+static char *CATDIR  = NULL;
+static SkyTable *sky = NULL;
 
-int GetRegionSelection () {
-  return (RegionSelect);
+int SetCATDIR (char *path, int verbose) {
+
+  char *newpath;
+  char catdir[256];
+  char gscfile[256];
+  char skyfile[256];
+  int  skydepth;
+
+  /* find CATDIR in config system */
+  if (path == NULL) {
+    if (VarConfig ("CATDIR", "%s", catdir) == NULL) return (FALSE);
+    newpath = catdir;
+  } else {
+    newpath = path;
+  }
+
+  if (CATDIR != NULL) free (CATDIR);
+  CATDIR = strcreate (newpath);
+
+  if (VarConfig ("GSCFILE",  "%s", gscfile) == NULL) gscfile[0] = 0;
+  if (VarConfig ("SKYFILE",  "%s", skyfile) == NULL) skyfile[0] = 0;
+  if (VarConfig ("SKYDEPTH", "%d", &skydepth) == NULL) skydepth = 2;
+
+  /* load the SkyTable at this point */
+  /* set the image path as well */
+
+  if (sky != NULL) SkyTableFree (sky);
+  sky = SkyTableLoadOptimal (catdir, skyfile, gscfile, skydepth, verbose);
+  SkyTableSetFilenames (sky, catdir, "cpt");
+
+  return (TRUE);
+}
+
+SkyTable *GetSkyTable () {
+  return (sky);
 }
 
@@ -14,6 +48,4 @@
   
   int N;
-
-  RegionSelect = FALSE;
 
   /* check for Region selection */
@@ -33,8 +65,5 @@
     return (TRUE);
   } 
-  if ((*RegionName == NULL) && (*RegionList == NULL)) {
-    RegionSelect = TRUE;
-    return (TRUE);
-  }
+  if ((*RegionName == NULL) && (*RegionList == NULL)) return (TRUE);
 
   fprintf (stderr, "-cpt and -cptlist are incompatible\n");
@@ -46,4 +75,5 @@
 }
 
+/* given possible options (by name, by list, by graph region), select SkyRegions */
 SkyList *SelectRegions (char *RegionName, char *RegionList) {
 
@@ -53,13 +83,14 @@
   SkyTable *sky;
   SkyList *skylist;
+  char filename[256];
 
   /* determine region-file names */
   if (RegionName != NULL) {
     ALLOCATE (skylist, SkyList, 1);
-    ALLOCATE (skylist[0].regions[0], SkyRegion *, 1);
-    ALLOCATE (skylist[0].regions[0][0], SkyRegion, 1);
+    ALLOCATE (skylist[0].regions, SkyRegion *, 1);
+    ALLOCATE (skylist[0].regions[0], SkyRegion, 1);
     strcpy (skylist[0].regions[0][0].name, RegionName);
     sprintf (filename, "%s/%s.cpt", CATDIR, RegionName);
-    skylist[0].regions[0][0].filename = strcreate (filename);
+    skylist[0].regions[0][0].filename = (e_void) strcreate (filename);
     free (RegionName);
     RegionName = NULL;
@@ -80,19 +111,14 @@
 
   Radius = MAX (fabs(graphsky.xmax), fabs(graphsky.ymax));
-
-  /* load sky from correct table */
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
-  SkyTableSetFilenames (sky, CATDIR, "cpt");
-  skylist = SkyListByRadius (sky, -1, graphmode.coords.crval1, graphmode.coords.crval2, Radius);
+  skylist = SkyListByRadius (sky, -1, graphsky.coords.crval1, graphsky.coords.crval2, Radius);
 
   return (skylist);
 }
 
-/* XXX EAM this should perhaps return a skytable? */
 /* returns a list of region files names from file */
-SkyList *SkyListFromFile (char *filename) {
+SkyList *SkyListLoadFile (char *filename) {
   
   FILE *f;
-  int NREGIONS, nregion;
+  int NREGIONS, Nregions;
   SkyList *skylist;
 
@@ -115,12 +141,10 @@
     strcpy (skylist[0].regions[Nregions][0].name, filename);
     sprintf (filename, "%s/%s.cpt", CATDIR, skylist[0].regions[Nregions][0].name);
-    skylist[0].regions[Nregions][0].filename = strcreate (filename);
+    skylist[0].regions[Nregions][0].filename = (e_void) strcreate (filename);
     Nregions ++;
     CHECK_REALLOCATE (skylist[0].regions, SkyRegion *, NREGIONS, Nregions, 50);
-    }
   }
-
-  *Nregions = nregion;
-  return (regions);
+  skylist[0].Nregions = Nregions;
+  return (skylist);
 }
 
Index: trunk/Ohana/src/opihi/dvo/skycat.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/skycat.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/skycat.c	(revision 5451)
@@ -1,3 +1,5 @@
 # include "dvo1.h"
+
+int RD_to_XYpic (double *x, double *y, double r, double d, Coords *coords, double Rmin, double Rmax, double Rmid, int *leftside);
 
 int skycat (int argc, char **argv) {
@@ -5,17 +7,12 @@
   double Radius;
   int i, j, N, Nregions, ShowAll, NPTS, Npts, leftside, Depth, TableDepth;
-  char filename[128];
   struct stat filestat;
   Vector Xvec, Yvec;
   Graphdata graphmode;
   double X[4], Y[4], Rmin, Rmax, Rmid;
-  char catdir[256], gscfile[256];
   int Ngraph, VERBOSE;
   SkyTable *sky;
   SkyList *skylist;
   SkyRegion **regions;
-
-  VarConfig ("CATDIR", "%s", catdir);
-  VarConfig ("GSCFILE", "%s", gscfile);
 
   VERBOSE = FALSE;
@@ -45,6 +42,6 @@
 
   Radius = MAX (fabs(graphmode.xmax), fabs(graphmode.ymax));
-  sky = SkyTableFromGSC (gscfile, TableDepth, VERBOSE);
-  if (sky == NULL) return (FALSE);
+
+  sky = GetSkyTable ();
   skylist = SkyListByRadius (sky, Depth, graphmode.coords.crval1, graphmode.coords.crval2, Radius);
   
@@ -66,6 +63,5 @@
 
   for (i = 0; i < Nregions; i++) {
-    sprintf (filename, "%s/%s", catdir, regions[i][0].name);
-    if (ShowAll || (stat (filename, &filestat) != -1)) {
+    if (ShowAll || (stat ((char *) regions[i][0].filename, &filestat) != -1)) {
       if (VERBOSE) fprintf (stderr, "%3d %s %6.2f - %6.2f, %6.2f - %6.2f\n", i, regions[i][0].name, 
 			    regions[i][0].Rmin, regions[i][0].Rmax, regions[i][0].Dmin, regions[i][0].Dmax);
@@ -114,2 +110,20 @@
 
 }
+
+
+int RD_to_XYpic (double *x, double *y, double r, double d, Coords *coords, double Rmin, double Rmax, double Rmid, int *leftside) {
+
+  while (r < Rmin) { r += 360.0; }
+  while (r > Rmax) { r -= 360.0; }
+
+  if (*leftside == -1) {
+    *leftside = (r < Rmid);
+  } else {
+    if (  *leftside && (r > Rmid + 90)) { r -= 360.0; }
+    if (! *leftside && (r < Rmid - 90)) { r += 360.0; }
+  }
+
+  RD_to_XY (x, y, r, d, coords);
+
+  return (TRUE);
+}
Index: trunk/Ohana/src/opihi/dvo/subpix.c
===================================================================
--- trunk/Ohana/src/opihi/dvo/subpix.c	(revision 5448)
+++ trunk/Ohana/src/opihi/dvo/subpix.c	(revision 5451)
@@ -13,6 +13,7 @@
   double Ra, Dec, Radius, Radius2, r, Rmin;
   double *RA, *DEC;
-  char catdir[256], filename[256];
   
+  SkyTable *sky;
+  SkyList *skylist;
   Measure *measure;
   Image *image;
@@ -20,6 +21,4 @@
 
   if (!InitPhotcodes ()) return (FALSE);
-
-  VarConfig ("CATDIR", "%s", catdir);
 
   GetTimeFormat (&TimeReference, &TimeFormat);
@@ -34,9 +33,6 @@
   Radius = atof (argv[3]);
 
-  /* load sky from correct table */
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, -1, VERBOSE);
-  SkyTableSetFilenames (sky, CATDIR, "cpt");
-
   /* load star nearest position */
+  sky = GetSkyTable ();
   skylist = SkyListByRadius (sky, -1, Ra, Dec, Radius);
   if (skylist[0].Nregions > 1) {
@@ -45,5 +41,5 @@
 
   /* lock, load, unlock catalog */
-  catalog.filename = skylist[0].regions[0][0].filename;
+  catalog.filename = (char *) skylist[0].regions[0][0].filename;
   switch (lock_catalog (&catalog, LCK_SOFT)) {
   case 2:
@@ -94,5 +90,5 @@
     if (catalog.average != 0) free (catalog.average);
     if (catalog.measure != 0) free (catalog.measure);
-    SkyListFree (skylist);
+    SkyListFree (skylist, FALSE);
     return (TRUE);
   }
@@ -160,5 +156,5 @@
   free (image);
   free (index);
-  SkyListFree (regions);
+  SkyListFree (skylist, FALSE);
 
   return (TRUE);
Index: trunk/Ohana/src/opihi/include/dvo1.h
===================================================================
--- trunk/Ohana/src/opihi/include/dvo1.h	(revision 5448)
+++ trunk/Ohana/src/opihi/include/dvo1.h	(revision 5451)
@@ -57,5 +57,4 @@
 int           GetMeasureTypeCode    PROTO((Measure *measure));
 int           GetPhotcodeInfo       PROTO((char *string, PhotCode **Code, int *Mode));
-int           GetRegionSelection    PROTO(());
 int           GetSelectionParam     PROTO(());
 int           GetTimeSelection      PROTO((time_t *tz, time_t *te));
@@ -68,27 +67,34 @@
 int           Quality               PROTO((Measure *measure, int IsDophot));
 int           SelectMags            PROTO((int Nphot, int Tphot, int Ns, Average *average, Measure *measure, SecFilt *secfilt, int UL));
-RegionFile   *SelectRegions         PROTO((char *RegionName, char *RegionList, int *nregions));
-int           SetImageSelection     PROTO((int mode));
+
+SkyList      *SelectRegions         PROTO((char *RegionName, char *RegionList));
+SkyList      *SkyListLoadFile       PROTO((char *filename));
+int           SetCATDIR             PROTO((char *path, int verbose));
+SkyTable     *GetSkyTable           PROTO(());
+SkyList      *SkyListFromFile       PROTO((char *filename));
+int           SetRegionSelection    PROTO((int *argc, char **argv, char **RegionName, char **RegionList));
+
+int           SetImageSelection     PROTO((int mode, int RegionSelect));
 int           SetPhotSelections     PROTO((int *argc, char **argv, int Nparams));
-int           SetRegionSelection    PROTO((int *argc, char **argv, char **RegionName, char **RegionList));
 int           SetSelectionParam     PROTO((int param));
 int           TestAverage           PROTO((PhotCode *code, Average *average, SecFilt *secfilt, Measure *measure));
 int           TestPhotSelections    PROTO((PhotCode **code, int *mode, int param));
-void          aregion               PROTO((GSCRegion *region, FILE *f, double ra, double dec, char *path));
 void          compare               PROTO((Catalog *catlog1, Catalog *catlog2, Vector *rvec,  Vector *dvec,  Vector *mvec, Vector *drvec, Vector *ddvec, Vector *dmvec, double radius));
 void          cprecess              PROTO((Average *average, int Naverage, double in_epoch, double out_epoch));
-RegionFile   *find_regions          PROTO((double Ra, double Dec, double radius, int *Nregions));
-GSCRegion    *get_regions           PROTO((Image *image, int *Nregions));
 void          image_subset          PROTO((Image *image, int Nimage, int **Subset, int *Nsubset, Graphdata *graph, int RegionSelect, unsigned long int tzero, double trange, int TimeSelect));
 int           match_image           PROTO((Image *image, int Nimage, unsigned int T, short int S));
 int           match_image_subset    PROTO((Image *image, int *subset, int Nsubset, unsigned int T, short int S));
 void          print_value           PROTO((FILE *f, double value, short int ival));
-RegionFile   *region_list           PROTO((char *filename, int *Nregions));
 void          sort_image_subset     PROTO((Image *image, int *subset, int N));
 void          sort_images           PROTO((Image *image, int N));
 void          sortave               PROTO((Average *ave, int N));
-CMPstars *cmpReadFits (FILE *f, int *nstars);
-CMPstars *cmpReadText (FILE *f, int *nstars);
-int RD_to_XYpic (double *x, double *y, double r, double d, Coords *coords, double Rmin, double Rmax, double Rmid, int *leftside);
+CMPstars     *cmpReadFits           PROTO((FILE *f, int *nstars));
+CMPstars     *cmpReadText           PROTO((FILE *f, int *nstars));
+int           RD_to_XYpic           PROTO((double *x, double *y, double r, double d, Coords *coords, double Rmin, double Rmax, double Rmid, int *leftside));
+
+RegionFile   *find_regions          PROTO((double Ra, double Dec, double radius, int *Nregions));
+GSCRegion    *get_regions           PROTO((Image *image, int *Nregions));
+RegionFile   *region_list           PROTO((char *filename, int *Nregions));
+void          aregion               PROTO((GSCRegion *region, FILE *f, double ra, double dec, char *path));
 
 # endif
