Index: /branches/eam_branches/ipp-20150616/Ohana/src/addstar/include/addstar.h
===================================================================
--- /branches/eam_branches/ipp-20150616/Ohana/src/addstar/include/addstar.h	(revision 38500)
+++ /branches/eam_branches/ipp-20150616/Ohana/src/addstar/include/addstar.h	(revision 38501)
@@ -190,4 +190,5 @@
 AddstarClientOptions args         	  PROTO((int argc, char **argv, AddstarClientOptions options));
 AddstarClientOptions args_parallel_client PROTO((int argc, char **argv, AddstarClientOptions options));
+void FreeConfig PROTO((void));
 
 void       AddToCalibration       PROTO((Average *average, SecFilt *secfilt, Measure *measure, Measure *new, off_t *next, off_t Nstar));
@@ -230,4 +231,5 @@
 Header   **LoadHeaders            PROTO((FILE *f, int *mode, int *Nheader));
 HeaderSet *MatchHeaders           PROTO((off_t **extsize, off_t *nimage, int mode, Header **headers, int Nheaders));
+void       HeaderSetFree          PROTO((HeaderSet *headerSets, off_t NheaderSets));
 int        LoadData               PROTO((FILE *f, char *file, Image **images, off_t *nvalid, Stars **stars, unsigned int *Nstars, Header **headers, off_t *extsize, HeaderSet *headerSets, int NheaderSets, AddstarClientOptions *options));
 int        GetZeroPointExposure   PROTO((Header **headers, HeaderSet *headerSets, off_t Nimages));
Index: /branches/eam_branches/ipp-20150616/Ohana/src/addstar/include/loadgalphot.h
===================================================================
--- /branches/eam_branches/ipp-20150616/Ohana/src/addstar/include/loadgalphot.h	(revision 38500)
+++ /branches/eam_branches/ipp-20150616/Ohana/src/addstar/include/loadgalphot.h	(revision 38501)
@@ -19,4 +19,6 @@
   double c11;
   double c02;
+  int ClipNiter;
+  float ClipNsigma;
 } Fit2D;
 
Index: /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/ConfigInit.c
===================================================================
--- /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/ConfigInit.c	(revision 38500)
+++ /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/ConfigInit.c	(revision 38501)
@@ -224,4 +224,5 @@
   }
 
+  FreeConfigFile();
   free (config);
   free (file);
@@ -240,2 +241,6 @@
   return;
 }
+
+void FreeConfig (void) {
+  FREE (CATDIR);
+}
Index: /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/ImageIndex.c
===================================================================
--- /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/ImageIndex.c	(revision 38500)
+++ /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/ImageIndex.c	(revision 38501)
@@ -1,3 +1,11 @@
 # include "addstar.h"
+
+void ImageIndexFree (ImageIndex *index) {
+  if (!index) return;
+  FREE (index->externID);
+  FREE (index->imageID);
+  FREE (index->found);
+  FREE (index);
+}
 
 ImageIndex *ImageIndexLoad (char *filename) {
@@ -16,4 +24,5 @@
   if (!f) {
     fprintf (stderr, "ERROR: cannot open image index file %s\n", filename);
+    FREE (index);
     return NULL;
   }
@@ -23,4 +32,5 @@
     if (VERBOSE) fprintf (stderr, "can't read image index header\n");
     fclose (f);
+    FREE (index);
     return NULL;
   }
@@ -28,8 +38,8 @@
     if (VERBOSE) fprintf (stderr, "can't read image index matrix\n");
     gfits_free_header (&header);
-    fclose (f);
-    return NULL;
-  }
-
+    FREE (index);
+    fclose (f);
+    return NULL;
+  }
   ftable.header = &theader;
 
@@ -37,4 +47,6 @@
   if (!gfits_load_header (f, &theader)) {
     fclose (f);
+    gfits_free_header (&header);
+    FREE (index);
     return NULL;
   }
@@ -43,4 +55,7 @@
   if (!gfits_fread_ftable_data (f, &ftable, FALSE)) {
     fclose (f);
+    gfits_free_header (&header);
+    gfits_free_header (&theader);
+    FREE (index);
     return (NULL);
   }
@@ -76,4 +91,9 @@
   }
 
+  gfits_free_header (&header);
+  gfits_free_matrix (&matrix);
+  gfits_free_header (&theader);
+  gfits_free_table (&ftable);
+
   return index;
 }
@@ -192,4 +212,5 @@
   // do this as an 'extend' operation
   ImageIndexSave (filename, index);
+  ImageIndexFree (index);
   return TRUE;
 }
@@ -209,4 +230,5 @@
   // do this as an 'extend' operation
   ImageIndexSave (filename, index);
+  ImageIndexFree (index);
   return TRUE;
 }
Index: /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadData.c
===================================================================
--- /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadData.c	(revision 38500)
+++ /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadData.c	(revision 38501)
@@ -106,4 +106,6 @@
     inStars = FilterStars (inStars, &images[0][Nvalid], Nvalid, options);
     *stars = MergeStars (*stars, Nstars, inStars, images[0][Nvalid].nstar);
+    FREE (inStars);
+
     Nvalid++;
     CHECK_REALLOCATE (images[0], Image, NVALID, Nvalid, 10);
Index: /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadHeaders.c
===================================================================
--- /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadHeaders.c	(revision 38500)
+++ /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadHeaders.c	(revision 38501)
@@ -17,4 +17,6 @@
     status = gfits_fread_header (f, headers[i]);
     if (!status) { 
+      gfits_free_header (headers[i]);
+      FREE (headers[i]);
       *Nheaders = i;
       return (headers);
Index: /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadStars.c
===================================================================
--- /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadStars.c	(revision 38500)
+++ /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/LoadStars.c	(revision 38501)
@@ -3,12 +3,10 @@
 Stars *LoadStars (char *filename, unsigned int *Nstars, Image **images, off_t *Nimages, AddstarClientOptions *options) {
 
-  off_t *extsize, NheaderSets;
-  int i, Nfile, NFILE, Nheaders, mode;
+  off_t *extsize;
+  int i, Nfile, NFILE, mode;
   char **file, line[1024];
   FILE *f;
   glob_t globList;
-  Header **headers;
   Stars *stars;
-  HeaderSet *headerSets;
 
   if (options[0].filelist) {
@@ -70,4 +68,9 @@
     }
 
+    int Nheaders = 0;
+    Header **headers = NULL;
+    off_t NheaderSets = 0;
+    HeaderSet *headerSets = NULL;
+
     // otherwise, we have FITS-table files: parse their headers to determine the contents
     headers = LoadHeaders (f, &mode, &Nheaders);
@@ -75,9 +78,9 @@
     if (headerSets == NULL) {
       fprintf (stderr, "ERROR: can't read headers for %s\n", file[i]);
-      continue;
+      goto next_file;
     }
     if (NheaderSets == 0) {
       fprintf (stderr, "no object data in file %s, skipping\n", file[i]);
-      continue;
+      goto next_file;
     }
     if (VERBOSE) fprintf (stderr, "file %s has %d headers, including "OFF_T_FMT" images\n", file[i], Nheaders,  NheaderSets);
@@ -97,5 +100,5 @@
     if (headerSets[0].exttype && !strcmp (headerSets[0].exttype, "SDSS_OBJ")) {
       LoadDataSDSS (f, file[i], images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets);
-      continue;
+      goto next_file;
     }
 
@@ -103,5 +106,5 @@
     if (headerSets[0].exttype && !strcmp (headerSets[0].exttype, "UKIRT_OBJ")) {
       LoadDataUKIRT (f, file[i], images, Nimages, &stars, Nstars, headers, extsize, headerSets, NheaderSets);
-      continue;
+      goto next_file;
     }
 
@@ -119,4 +122,13 @@
     # endif
 
+  next_file:
+    HeaderSetFree (headerSets, NheaderSets);
+    int j;
+    for (j = 0; j < Nheaders; j++) {
+      gfits_free_header (headers[j]);
+      FREE (headers[j]);
+    }
+    FREE (headers);
+    FREE (extsize);
   }
 
@@ -129,4 +141,9 @@
   }
 
+  for (i = 0; i < Nfile; i++) {
+    FREE (file[i]); 
+  }
+  FREE (file);
+
   return stars;
 }
Index: /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/MatchHeaders.c
===================================================================
--- /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/MatchHeaders.c	(revision 38500)
+++ /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/MatchHeaders.c	(revision 38501)
@@ -2,4 +2,17 @@
 
 // XXX largely psphot specific
+
+void HeaderSetFree (HeaderSet *headerSets, off_t NheaderSets) {
+  int i;
+
+  if (!headerSets) return;
+  for (i = 0; i < NheaderSets; i++) {
+    FREE (headerSets[i].exthead);
+    FREE (headerSets[i].exttype);
+    FREE (headerSets[i].extdata);
+    FREE (headerSets[i].extxrad);
+  }
+  FREE (headerSets);
+}
 
 HeaderSet *MatchHeaders (off_t **extsize, off_t *nimage, int mode, Header **headers, int Nheaders) {
@@ -22,4 +35,6 @@
     headerSets[Nimage].exthead     = strcreate ("PHU");
     headerSets[Nimage].extdata     = strcreate ("NONE");
+    headerSets[Nimage].exttype     = NULL;
+    headerSets[Nimage].extxrad     = NULL;
     headerSets[Nimage].extnum_data = -1;
     headerSets[Nimage].extnum_head =  0;
@@ -34,4 +49,5 @@
     headerSets[0].exttype     = strcreate ("SDSS_OBJ");
     headerSets[0].exthead     = strcreate ("PHU");
+    headerSets[0].extxrad     = NULL;
     headerSets[0].extnum_head = 0;
     headerSets[0].extnum_data = 1;
@@ -112,9 +128,8 @@
 
   keep:
-    headerSets[Nimage].exttype = strcreate (exttype);
-
     gfits_scan (headers[i], ExtnameKeyword, "%s", 1, extname);
     gfits_scan (headers[i], "EXTHEAD", "%s", 1, exthead);
 
+    headerSets[Nimage].exttype     = strcreate (exttype);
     headerSets[Nimage].extdata     = strcreate (extname);
     headerSets[Nimage].exthead     = strcreate (exthead);
@@ -171,4 +186,5 @@
       headerSets[Nimage].exttype     = strcreate ("SMPDATA");
       headerSets[Nimage].exthead     = strcreate ("PHU");
+      headerSets[Nimage].extxrad     = NULL;
       headerSets[Nimage].extnum_head = 0;
       headerSets[Nimage].extnum_data = 1;
Index: /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/ReadStarsFITS.c
===================================================================
--- /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/ReadStarsFITS.c	(revision 38500)
+++ /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/ReadStarsFITS.c	(revision 38501)
@@ -125,4 +125,7 @@
     return (NULL);
   }
+
+  gfits_free_table (&table);
+
   // Nstars is not necessarily == *nstars (The former is the number of detections, the
   // latter are the 'good' detections reported by the photometry system.
Index: /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/UpdateImageIDs.c
===================================================================
--- /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/UpdateImageIDs.c	(revision 38500)
+++ /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/UpdateImageIDs.c	(revision 38501)
@@ -87,4 +87,5 @@
 
   dvo_image_unlock (&db);
+  gfits_db_free (&db);
 
   return TRUE;
Index: /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/addstar.c
===================================================================
--- /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/addstar.c	(revision 38500)
+++ /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/addstar.c	(revision 38501)
@@ -10,6 +10,4 @@
   off_t i, Nimages;
   off_t Naverage, Nmeasure, Nlensing;
-  Stars *stars, **subset;
-  Image *images;
   Catalog catalog;
   FITS_DB db;
@@ -48,5 +46,6 @@
   MARKTIME ("init and config: %f sec\n", dtime); RESETTIME; 
 
-  stars = NULL;
+  Stars *stars = NULL;
+  Image *images = NULL;
 
   /*** load in the new data (images, stars) ***/
@@ -155,6 +154,6 @@
       case ADDSTAR_MODE_REFCAT:
 	stars = greference (argv[1], skylist[0].regions[i], options.photcode, &Nstars);
-      case ADDSTAR_MODE_REFLIST:
-	subset = find_subset (skylist[0].regions[i], stars, Nstars, &Nsubset);
+      case ADDSTAR_MODE_REFLIST: {
+	Stars **subset = find_subset (skylist[0].regions[i], stars, Nstars, &Nsubset);
 	if (options.closest) {
 	  Nmatch += find_matches_closest_refstars (skylist[0].regions[i], subset, Nsubset, &catalog, options);
@@ -164,4 +163,5 @@
 	if (Nsubset) free (subset);
 	break;
+      }
     }
     if (VERBOSE) MARKTIME ("match stars: %f sec\n", dtime); RESETTIME; 
@@ -189,4 +189,9 @@
     if (options.mode == ADDSTAR_MODE_REFCAT) free (stars);
   }
+  SkyListFree (skylist);
+
+  if (options.mode != ADDSTAR_MODE_REFCAT) {
+    FREE (stars);
+  }
 
   // We only measure a single value for the entire mosaic (add all images to this function)
@@ -218,5 +223,7 @@
     SetProtect (FALSE);
   }
+  FREE (images);
   dvo_image_unlock (&db); /* unlock? */
+  gfits_db_free (&db); /* unlock? */
 
   gettimeofday (&stopAddstar, (void *) NULL);
@@ -224,4 +231,10 @@
   fprintf (stderr, "SUCCESS: elapsed time %9.4f sec for %5d stars (%5d matches), "OFF_T_FMT" average, "OFF_T_FMT" measure, "OFF_T_FMT" lensing\n", dtime, Nstars, Nmatch,  Naverage,  Nmeasure, Nlensing);
 
+  // XXX test
+  FreeConfig ();
+  FreePhotcodeTable ();
+  SkyTableFree (sky);
+  ohana_memcheck (1);
+  ohana_memdump (1);
   exit (0);
 }
Index: /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/loadgalphot_fit2d.c
===================================================================
--- /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/loadgalphot_fit2d.c	(revision 38500)
+++ /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/loadgalphot_fit2d.c	(revision 38501)
@@ -15,4 +15,7 @@
   fit->wterm = fit->nterm*(fit->nterm + 1)/2;
   fit->mterm = 2*order + 1;
+
+  fit->ClipNiter = 1;
+  fit->ClipNsigma = 0.0;
 
   /* allocate the summation matrices */
@@ -87,8 +90,5 @@
   float *x, *y, *z, *zf;
 
-  float ClipNSigma = 0;
-  int ClipNiter  = 1;
-
-  for (N = 0; N < ClipNiter; N++) {
+  for (N = 0; N < fit->ClipNiter; N++) {
     fit2d_reset (fit);
 
@@ -209,5 +209,5 @@
     mean  = dZ / Npt;
     sigma = sqrt (fabs(dZ2/Npt - SQ(mean)));
-    maxsigma = ClipNSigma * sigma;
+    maxsigma = fit->ClipNsigma * sigma;
 
     // if (VERBOSE) gprint (GP_ERR, "mean: %g, sigma: %g, maxsigma: %g\n", mean, sigma, maxsigma);
@@ -219,5 +219,5 @@
     zf = zfit;
     int Nmask = 0;
-    for (i = 0; ClipNSigma && (i < Npts); i++, x++, y++, z++, zf++) {
+    for (i = 0; fabs(fit->ClipNsigma) > 0.001 && (i < Npts); i++, x++, y++, z++, zf++) {
       float dZi = (*z - *zf);
       if (fabs(dZi) > maxsigma) {
Index: /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/loadgalphot_readstars.c
===================================================================
--- /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/loadgalphot_readstars.c	(revision 38500)
+++ /branches/eam_branches/ipp-20150616/Ohana/src/addstar/src/loadgalphot_readstars.c	(revision 38501)
@@ -35,4 +35,42 @@
     fclose (f);
     return NULL;
+  }
+
+  {
+    Header header_xfit;
+    FTable ftable_xfit;
+
+    if (!gfits_find_Xheader (f, &header_xfit, "SkyChip.xfit")) {
+      if (VERBOSE) fprintf (stderr, "can't read galaxy photometry header\n");
+      gfits_free_header (&header_xfit);
+      gfits_free_header (&PHU);
+      fclose (f);
+      return NULL;
+    }
+
+    ftable_xfit.header = &header_xfit;
+
+    if (!gfits_fread_ftable_data (f, &ftable_xfit, FALSE)) {
+      if (VERBOSE) fprintf (stderr, "can't read galaxy photometry data\n");
+      gfits_free_header (&header_xfit);
+      gfits_free_header (&PHU);
+      fclose (f);
+      return (NULL);
+    }
+
+    char type[16];
+    int firstCol = TRUE;
+
+    GET_COLUMN (ID_fit,        "IPP_IDET",      int);
+    GET_COLUMN (MODEL_TYPE_fit,"MODEL_TYPE",    char); NcharModel = Ncol;.
+    GET_COLUMN (EXT_WIDTH_MAJ, "EXT_WIDTH_MAJ", float);
+    GET_COLUMN (EXT_WIDTH_MIN, "EXT_WIDTH_MIN", float);
+    GET_COLUMN (EXT_THETA,     "EXT_THETA",     float);
+    GET_COLUMN (EXT_THETA_ERR, "EXT_THETA_ERR", float);
+    GET_COLUMN (INDEX,         "EXT_PAR_07",    float);
+
+    // free the memory associated with the FITS files
+    gfits_free_header (&header);
+    gfits_free_table (&ftable);
   }
 
@@ -92,4 +130,6 @@
 
   Fit2D *fit = fit2d_init (2);
+  fit->ClipNiter = 3;
+  fit->ClipNsigma = 5.0;
 
   int Nbad = 0;
@@ -185,11 +225,14 @@
     Xpt[i] = MajorMin + MajorDel*iX;
     Ypt[i] = MinorMin + MinorDel*iY;
+    Nvalid ++;
     if (chisq[i] < chisqMin) {
       chisqMin = chisq[i];
       iMin = i;
-      Nvalid ++;
-    }
-  }
-  if (!Nvalid) return FALSE; // we cannot do anything if there is no finite chisq
+    }
+  }
+  if (!Nvalid) {
+    fprintf (stderr, "no good points\n");
+    return FALSE; // we cannot do anything if there is no finite chisq
+  }
   
   if (Nvalid < 6) {
@@ -198,47 +241,8 @@
     galphot->majorAxisErr = MajorDel;
     galphot->minorAxisErr = MinorDel;
+    fprintf (stderr, "too few good points: %d\n", Nvalid);
     return FALSE;
   }
 
-  // find the list of distances from the min point
-  for (i = 0; i < Npts; i++) {
-    Rpt[i] = hypot(Xpt[i] - Xpt[iMin], Ypt[i] - Ypt[iMin]);
-    // only include unmasked points
-    if (mask[i]) {
-      Rsr[i] = FLT_MAX;
-    } else {
-      Rsr[i] = Rpt[i];
-    }
-  }
-
-  // sorts the distances in ascending order
-  fsort (Rsr, Npts);
-  int Nmin = MIN(Nvalid, 9);
-
-  float Rmax = Rsr[Nmin-1];
-  for (i = 0; i < Npts; i++) {
-    if (Rpt[i] > Rmax) mask[i] = TRUE;
-  }
-
-  // fit the inner 9 points
-  if (!fit2d (fit, Xpt, Ypt, chisq, chisqFit, mask, Npts)) {
-    // raise a flag?
-    galphot->majorAxis = Xpt[iMin];
-    galphot->minorAxis = Ypt[iMin];
-    galphot->majorAxisErr = MajorDel;
-    galphot->minorAxisErr = MinorDel;
-    return FALSE;
-  }
-
-  // exclude any extreme outliers
-  float maxSigma = 5.0*fit->sigma;
-
-  memset (mask, 0, Npts*sizeof(char));
-  for (i = 0; i < Npts; i++) {
-    if (!isfinite(chisq[i])) { mask[i] = TRUE; continue; }
-    float dZ = chisq[i] - chisqFit[i];
-    if (fabs(dZ) > maxSigma) { mask[i] = TRUE; continue; }
-  }
-  
   // re-fit all except the most extreme set
   if (!fit2d (fit, Xpt, Ypt, chisq, chisqFit, mask, Npts)) {
@@ -248,4 +252,5 @@
     galphot->majorAxisErr = MajorDel;
     galphot->minorAxisErr = MinorDel;
+    fprintf (stderr, "failed fit\n");
     return FALSE;
   }
Index: /branches/eam_branches/ipp-20150616/Ohana/src/addstar/test/dvomerge.dvo
===================================================================
--- /branches/eam_branches/ipp-20150616/Ohana/src/addstar/test/dvomerge.dvo	(revision 38500)
+++ /branches/eam_branches/ipp-20150616/Ohana/src/addstar/test/dvomerge.dvo	(revision 38501)
@@ -2,4 +2,9 @@
 
 input tap.dvo
+
+macro test.all
+  $TAP_VERBOSE = 1
+  test.dvomerge.update.new
+end
 
 # create 2 populated catdirs, each with a couple of cmf files
@@ -8,7 +13,7 @@
   tapPLAN 51
 
-  exec rm -rf catdir.test1
-  exec rm -rf catdir.test2
-  exec rm -rf catdir.test3
+  tapEXEC rm -rf catdir.test1
+  tapEXEC rm -rf catdir.test2
+  tapEXEC rm -rf catdir.test3
 
   $RA = 10.0
@@ -16,34 +21,34 @@
 
   mkinput
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec 10.0 20.0
-  exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf
-
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec 10.0 20.0
-  exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf
-
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 03:00:00 -radec 9.9 20.0
-  exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf
-
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 04:00:00 -radec 9.9 20.0
-  exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf
-
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 05:00:00 -radec 10.0 19.9
-  exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf
-
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 06:00:00 -radec 10.0 19.9
-  exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf
-
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 07:00:00 -radec 9.9 19.9
-  exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf
-
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 08:00:00 -radec 9.9 19.9
-  exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec 10.0 20.0
+  tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf -quick-airmass
+
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec 10.0 20.0
+  tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf -quick-airmass
+
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 03:00:00 -radec 9.9 20.0
+  tapEXEC addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf -quick-airmass
+
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 04:00:00 -radec 9.9 20.0
+  tapEXEC addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf -quick-airmass
+
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 05:00:00 -radec 10.0 19.9
+  tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf -quick-airmass
+
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 06:00:00 -radec 10.0 19.9
+  tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf -quick-airmass
+
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 07:00:00 -radec 9.9 19.9
+  tapEXEC addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf -quick-airmass
+
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 08:00:00 -radec 9.9 19.9
+  tapEXEC addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf -quick-airmass
 
   break
 
-  exec rsync -auc catdir.test2/ catdir.test3/
+  tapEXEC rsync -auc catdir.test2/ catdir.test3/
 
   date -var t1 -seconds -reftime 1276000000
-  exec dvomerge catdir.test1 into catdir.test3
+  tapEXEC dvomerge catdir.test1 into catdir.test3
   date -var t2 -seconds -reftime 1276000000
   echo "merge time: {$t2 - $t1}"
@@ -114,8 +119,8 @@
   end
 
-  # exec rm test.in.txt test.cmf
-  # exec rm -rf catdir.test1
-  # exec rm -rf catdir.test2
-  # exec rm -rf catdir.test3
+  # tapEXEC rm test.in.txt test.cmf
+  # tapEXEC rm -rf catdir.test1
+  # tapEXEC rm -rf catdir.test2
+  # tapEXEC rm -rf catdir.test3
 
   tapDONE
@@ -127,7 +132,7 @@
   tapPLAN 51
 
-  exec rm -rf catdir.test1
-  exec rm -rf catdir.test2
-  exec rm -rf catdir.test3
+  tapEXEC rm -rf catdir.test1
+  tapEXEC rm -rf catdir.test2
+  tapEXEC rm -rf catdir.test3
 
   $RA = 10.0
@@ -135,22 +140,20 @@
 
   mkinput
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC
-  exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf
-
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec $RA $DEC
-  exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf
-
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 03:00:00 -radec $RA $DEC
-  exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf
-
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 04:00:00 -radec $RA $DEC
-  exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf
-
-  break
-
-  exec rsync -auc catdir.test2/ catdir.test3/
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC
+  tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf -quick-airmass
+
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec $RA $DEC
+  tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf -quick-airmass
+
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 03:00:00 -radec $RA $DEC
+  tapEXEC addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf -quick-airmass
+
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 04:00:00 -radec $RA $DEC
+  tapEXEC addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf -quick-airmass
+
+  tapEXEC rsync -auc catdir.test2/ catdir.test3/
 
   date -var t1 -seconds -reftime 1276000000
-  exec dvomerge catdir.test1 into catdir.test3
+  tapEXEC dvomerge catdir.test1 into catdir.test3
   date -var t2 -seconds -reftime 1276000000
   echo "merge time: {$t2 - $t1}"
@@ -221,8 +224,8 @@
   end
 
-  # exec rm test.in.txt test.cmf
-  # exec rm -rf catdir.test1
-  # exec rm -rf catdir.test2
-  # exec rm -rf catdir.test3
+  # tapEXEC rm test.in.txt test.cmf
+  # tapEXEC rm -rf catdir.test1
+  # tapEXEC rm -rf catdir.test2
+  # tapEXEC rm -rf catdir.test3
 
   tapDONE
@@ -234,6 +237,6 @@
   tapPLAN 51
 
-  exec rm -rf catdir.test1
-  exec rm -rf catdir.test2
+  tapEXEC rm -rf catdir.test1
+  tapEXEC rm -rf catdir.test2
 
   $RA = 10.0
@@ -241,12 +244,12 @@
 
   mkinput
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC
-  exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf
-
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec $RA $DEC
-  exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC
+  tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf -quick-airmass
+
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec $RA $DEC
+  tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf -quick-airmass
 
   date -var t1 -seconds -reftime 1276000000
-  exec dvomerge catdir.test1 into catdir.test2
+  tapEXEC dvomerge catdir.test1 into catdir.test2
   date -var t2 -seconds -reftime 1276000000
   echo "merge time: {$t2 - $t1}"
@@ -297,8 +300,8 @@
   end
 
-  # exec rm test.in.txt test.cmf
-  # exec rm -rf catdir.test1
-  # exec rm -rf catdir.test2
-  # exec rm -rf catdir.test3
+  # tapEXEC rm test.in.txt test.cmf
+  # tapEXEC rm -rf catdir.test1
+  # tapEXEC rm -rf catdir.test2
+  # tapEXEC rm -rf catdir.test3
 
   tapDONE
@@ -310,7 +313,7 @@
   tapPLAN 51
 
-  exec rm -rf catdir.test1
-  exec rm -rf catdir.test2
-  exec rm -rf catdir.test3
+  tapEXEC rm -rf catdir.test1
+  tapEXEC rm -rf catdir.test2
+  tapEXEC rm -rf catdir.test3
 
   $RA = 10.0
@@ -318,21 +321,21 @@
 
   mkinput
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC
-  exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf
-
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec $RA $DEC
-  exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC
+  tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf -quick-airmass
+
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec $RA $DEC
+  tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf -quick-airmass
 
   # generate a few extra unmatched sources 
   mkinput.extras
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 03:00:00 -radec $RA $DEC
-  exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf
-
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 04:00:00 -radec $RA $DEC
-  exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf
-
-  exec rsync -auc catdir.test2/ catdir.test3/
-
-  exec dvomerge catdir.test1 into catdir.test3
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 03:00:00 -radec $RA $DEC
+  tapEXEC addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf -quick-airmass
+
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 04:00:00 -radec $RA $DEC
+  tapEXEC addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf -quick-airmass
+
+  tapEXEC rsync -auc catdir.test2/ catdir.test3/
+
+  tapEXEC dvomerge catdir.test1 into catdir.test3
 
   catdir catdir.test3
@@ -401,8 +404,8 @@
   end
 
-  # exec rm test.in.txt test.cmf
-  # exec rm -rf catdir.test1
-  # exec rm -rf catdir.test2
-  # exec rm -rf catdir.test3
+  # tapEXEC rm test.in.txt test.cmf
+  # tapEXEC rm -rf catdir.test1
+  # tapEXEC rm -rf catdir.test2
+  # tapEXEC rm -rf catdir.test3
 
   tapDONE
@@ -414,7 +417,7 @@
   tapPLAN 21
 
-  exec rm -rf catdir.test1
-  exec rm -rf catdir.test2
-  exec rm -rf catdir.test3
+  tapEXEC rm -rf catdir.test1
+  tapEXEC rm -rf catdir.test2
+  tapEXEC rm -rf catdir.test3
 
   $RA = 10.0
@@ -422,17 +425,17 @@
 
   mkinput
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC
-  exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf
-
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec $RA $DEC
-  exec addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf
-
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 03:00:00 -radec $RA $DEC
-  exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf
-
-  exec mkcmf test.in.txt test.cmf -date 2008/1/1 -time 04:00:00 -radec $RA $DEC
-  exec addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf
-
-  exec dvomerge catdir.test1 and catdir.test2 to catdir.test3
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 01:00:00 -radec $RA $DEC
+  tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf -quick-airmass
+
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 02:00:00 -radec $RA $DEC
+  tapEXEC addstar -D CATDIR catdir.test1 -D CAMERA simtest test.cmf -quick-airmass
+
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 03:00:00 -radec $RA $DEC
+  tapEXEC addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf -quick-airmass
+
+  tapEXEC mkcmf test.in.txt test.cmf -date 2008/1/1 -time 04:00:00 -radec $RA $DEC
+  tapEXEC addstar -D CATDIR catdir.test2 -D CAMERA simtest test.cmf -quick-airmass
+
+  tapEXEC dvomerge catdir.test1 and catdir.test2 to catdir.test3
 
   catdir catdir.test3
@@ -501,8 +504,8 @@
   end
 
-  # exec rm test.in.txt test.cmf
-  # exec rm -rf catdir.test1
-  # exec rm -rf catdir.test2
-  # exec rm -rf catdir.test3
+  # tapEXEC rm test.in.txt test.cmf
+  # tapEXEC rm -rf catdir.test1
+  # tapEXEC rm -rf catdir.test2
+  # tapEXEC rm -rf catdir.test3
 
   tapDONE
@@ -511,5 +514,5 @@
 # make a simple input file for mkcmf
 macro mkinput.alt
-  exec rm -f test.in.txt
+  tapEXEC rm -f test.in.txt
 
   output test.in.txt
@@ -524,5 +527,5 @@
 # make a simple input file for mkcmf
 macro mkinput
-  exec rm -f test.in.txt
+  tapEXEC rm -f test.in.txt
 
   output test.in.txt
@@ -537,5 +540,5 @@
 # make a simple input file for mkcmf
 macro mkinput.extras
-  exec rm -f test.in.txt
+  tapEXEC rm -f test.in.txt
 
   output test.in.txt
