Index: /trunk/Ohana/src/relphot/Makefile
===================================================================
--- /trunk/Ohana/src/relphot/Makefile	(revision 39477)
+++ /trunk/Ohana/src/relphot/Makefile	(revision 39478)
@@ -92,4 +92,6 @@
 $(SRC)/initialize.$(ARCH).o	 \
 $(SRC)/syncfile.$(ARCH).o	 \
+$(SRC)/select_images.$(ARCH).o	 \
+$(SRC)/load_images.$(ARCH).o	 \
 $(SRC)/load_catalogs.$(ARCH).o	 \
 $(SRC)/reload_catalogs.$(ARCH).o \
Index: /trunk/Ohana/src/relphot/include/relphot.h
===================================================================
--- /trunk/Ohana/src/relphot/include/relphot.h	(revision 39477)
+++ /trunk/Ohana/src/relphot/include/relphot.h	(revision 39478)
@@ -418,5 +418,5 @@
 Catalog      *load_catalogs_parallel PROTO((SkyList *sky, int *Ncatalog, char *syncfile));
 
-SkyList      *load_images         PROTO((FITS_DB *db, char *regionName, SkyRegion *region));
+SkyList      *load_images         PROTO((FITS_DB *db, SkyTable *sky, char *regionName, SkyRegion *region));
 Image        *select_images       PROTO((SkyList *skylist, Image *timage, off_t Ntimage, char *inSubset, off_t **LineNumber, off_t *Nimage, SkyRegion *region));
 
@@ -475,5 +475,5 @@
 void          wimages             PROTO((void));
 void          write_coords        PROTO((Header *header, Coords *coords));
-int relphot_objects (int hostID, char *hostpath);
+int relphot_objects (SkyTable *sky, SkyList *skylist, int hostID, char *hostpath);
 int relphot_images (void);
 
@@ -597,2 +597,8 @@
 int getMosaicFlags (off_t meas, int cat);
 
+void relphot_free (SkyTable *sky, SkyList *skylist);
+void freeImages ();
+void relphot_client_free (SkyTable *sky, SkyList *skylist);
+void BrightCatalogFree (BrightCatalog *bcatalog);
+
+void free_astrom_table ();
Index: /trunk/Ohana/src/relphot/src/BrightCatalog.c
===================================================================
--- /trunk/Ohana/src/relphot/src/BrightCatalog.c	(revision 39477)
+++ /trunk/Ohana/src/relphot/src/BrightCatalog.c	(revision 39478)
@@ -547,4 +547,13 @@
 }
 
+void BrightCatalogFree (BrightCatalog *bcatalog) {
+  if (!bcatalog) return;
+  FREE (bcatalog[0].average);
+  FREE (bcatalog[0].measure);
+  FREE (bcatalog[0].secfilt);
+  FREE (bcatalog);
+  return;
+}
+
 // distribute a bright catalog across separate catalogs
 CatalogSplitter *BrightCatalogSplitInit (int Nsecfilt) {
Index: /trunk/Ohana/src/relphot/src/ConfigInit.c
===================================================================
--- /trunk/Ohana/src/relphot/src/ConfigInit.c	(revision 39477)
+++ /trunk/Ohana/src/relphot/src/ConfigInit.c	(revision 39478)
@@ -73,4 +73,5 @@
   SetZeroPoint (ZERO_POINT);
 
+  FreeConfigFile();
   free (config);
   free (file);
Index: /trunk/Ohana/src/relphot/src/ImageOps.c
===================================================================
--- /trunk/Ohana/src/relphot/src/ImageOps.c	(revision 39477)
+++ /trunk/Ohana/src/relphot/src/ImageOps.c	(revision 39478)
@@ -265,4 +265,19 @@
     free (N_ONIMAGE);
   }
+}
+
+void freeImages () {
+
+  FREE (image);
+  FREE (LineNumber);
+
+  FREE (imageIDs);
+  FREE (imageIdx);
+
+  FREE (tessID);
+  FREE (projectID);
+  FREE (skycellID);
+
+  free_astrom_table();
 }
 
Index: /trunk/Ohana/src/relphot/src/ImageSubset.c
===================================================================
--- /trunk/Ohana/src/relphot/src/ImageSubset.c	(revision 39477)
+++ /trunk/Ohana/src/relphot/src/ImageSubset.c	(revision 39478)
@@ -43,4 +43,6 @@
   if (!gfits_load_header (f, &theader)) {
     fclose (f);
+    gfits_free_header (&header);
+    gfits_free_matrix (&matrix);
     return NULL;
   }
@@ -49,4 +51,7 @@
   if (!gfits_fread_ftable_data (f, &ftable, FALSE)) {
     fclose (f);
+    gfits_free_header (&theader);
+    gfits_free_header (&header);
+    gfits_free_matrix (&matrix);
     return (NULL);
   }
@@ -100,4 +105,9 @@
   free (ucdist);
 
+  gfits_free_header (&header);
+  gfits_free_matrix (&matrix);
+  gfits_free_header (&theader);
+  gfits_free_table  (&ftable);
+
   *nimage = Nrow;
   return image;
Index: /trunk/Ohana/src/relphot/src/MosaicOps.c
===================================================================
--- /trunk/Ohana/src/relphot/src/MosaicOps.c	(revision 39477)
+++ /trunk/Ohana/src/relphot/src/MosaicOps.c	(revision 39478)
@@ -313,4 +313,7 @@
   fprintf (stderr, "matched %d images to %d mosaics, %d simple chips not matched to mosaics\n", (int) (Nsubset - Nsimple), (int) Nmosaic, (int) Nsimple);
   return;
+}
+
+void freeMosaics () {
 }
 
Index: /trunk/Ohana/src/relphot/src/StarOps.c
===================================================================
--- /trunk/Ohana/src/relphot/src/StarOps.c	(revision 39477)
+++ /trunk/Ohana/src/relphot/src/StarOps.c	(revision 39478)
@@ -302,4 +302,5 @@
 
   SetMrelInfoFree (&results);
+  SetMrelInfoFree (&summary);
 
   return (TRUE);
@@ -324,4 +325,5 @@
 
   SetMrelInfoFree (&results);
+  SetMrelInfoFree (&summary);
   return (TRUE);
 }
@@ -387,8 +389,10 @@
 	     threadinfo[i].summary.Nsys);
     SetMrelInfoAccum (&summary, &threadinfo[i].summary);
+    SetMrelInfoFree (&threadinfo[i].summary);
   }
   if (VERBOSE2) fprintf (stderr, "total : %d stars with no data in photcode, %d stars marked having too few measurements (Nbad: %d, Ncal: %d, Nmos: %d, Ngrid: %d, Nsys: %d)\n", summary.Ncode, summary.Nfew, summary.Nbad, summary.Ncal, summary.Nmos, summary.Ngrid, summary.Nsys);
   free (threadinfo);
 
+  SetMrelInfoFree (&summary);
   return TRUE;
 }
@@ -407,4 +411,5 @@
     if (i == -1) {
       threadinfo->state = THREAD_DONE;
+      SetMrelInfoFree (&results);
       return NULL;
     }
Index: /trunk/Ohana/src/relphot/src/args.c
===================================================================
--- /trunk/Ohana/src/relphot/src/args.c	(revision 39477)
+++ /trunk/Ohana/src/relphot/src/args.c	(revision 39478)
@@ -441,4 +441,6 @@
   }
 
+  PhotcodeList = NULL;
+  photcodes = NULL;
   switch (mode) {
     case SYNTH_PHOT:
@@ -450,4 +452,5 @@
     case PARALLEL_IMAGES:
     case PARALLEL_REGIONS:
+    case APPLY_OFFSETS:
       PhotcodeList = strcreate (argv[1]);
       photcodes = ParsePhotcodeList (PhotcodeList, &Nphotcodes, TRUE); // require SEC photcodes
@@ -465,4 +468,27 @@
 }
 
+// XXX need to free sky
+void relphot_free (SkyTable *sky, SkyList *skylist) {
+  FREE (UserCatalog);
+  FREE (OUTROOT);
+  FREE (UPDATE_CATFORMAT);
+
+  FREE (BOUNDARY_TREE);
+  FREE (REGION_FILE);
+  FREE (SYNTH_ZERO_POINTS);
+  FREE (IMAGE_TABLE);
+  FREE (CATDIR);
+
+  FREE (PhotcodeList);
+  FREE (photcodes);
+  
+  SkyTableFree (sky);
+  SkyListFree(skylist);
+  FreePhotcodeTable();
+  
+  ohana_memcheck (VERBOSE);
+  ohana_memdump (VERBOSE);
+}
+
 int args_client (int argc, char **argv) {
 
@@ -470,5 +496,5 @@
   double trange;
 
-  // by definition, the client is not parallel 
+ // by definition, the client is not parallel 
   PARALLEL = FALSE;
   PARALLEL_MANUAL = FALSE;
@@ -722,2 +748,25 @@
 }
 
+// XXX need to free sky
+void relphot_client_free (SkyTable *sky, SkyList *skylist) {
+  FREE (HOSTDIR);
+  FREE (BCATALOG);
+  FREE (IMAGES);
+
+  FREE (SYNTH_ZERO_POINTS);
+  FREE (BOUNDARY_TREE);
+  FREE (UPDATE_CATFORMAT);
+
+  FREE (CATDIR);
+  FREE (PhotcodeList);
+  FREE (photcodes);
+  
+  SkyTableFree (sky);
+  SkyListFree(skylist);
+  FreePhotcodeTable();
+  
+  ohana_memcheck (VERBOSE);
+  ohana_memdump (VERBOSE);
+}
+
+
Index: /trunk/Ohana/src/relphot/src/bcatalog.c
===================================================================
--- /trunk/Ohana/src/relphot/src/bcatalog.c	(revision 39477)
+++ /trunk/Ohana/src/relphot/src/bcatalog.c	(revision 39478)
@@ -239,4 +239,6 @@
   }
 
+  free (Nvalid)
+
   return (TRUE);
 }
Index: /trunk/Ohana/src/relphot/src/client_logger.c
===================================================================
--- /trunk/Ohana/src/relphot/src/client_logger.c	(revision 39477)
+++ /trunk/Ohana/src/relphot/src/client_logger.c	(revision 39478)
@@ -27,4 +27,6 @@
 int client_logger_message (char *format,...) {
 
+  if (!logfile) return FALSE;
+
   va_list argp;
 
Index: /trunk/Ohana/src/relphot/src/initialize.c
===================================================================
--- /trunk/Ohana/src/relphot/src/initialize.c	(revision 39477)
+++ /trunk/Ohana/src/relphot/src/initialize.c	(revision 39478)
@@ -92,4 +92,6 @@
 
   // XXX need to determine which globals can affect relphot_client in either mode and pass appropriately
+  PhotcodeList = NULL;
+  photcodes = NULL;
 
   relphot_client_help (argc, argv);
Index: /trunk/Ohana/src/relphot/src/load_catalogs.c
===================================================================
--- /trunk/Ohana/src/relphot/src/load_catalogs.c	(revision 39477)
+++ /trunk/Ohana/src/relphot/src/load_catalogs.c	(revision 39478)
@@ -176,5 +176,8 @@
     fprintf (stderr, "command: %s\n", command);
 
-    if (PARALLEL_MANUAL) continue;
+    if (PARALLEL_MANUAL) {
+      free (command);
+      continue;
+    }
 
     if (PARALLEL_SERIAL) {
@@ -194,4 +197,5 @@
       table->hosts[i].pid = pid; // save for future reference
     }
+    free (command);
   }
 
@@ -254,4 +258,11 @@
   *Ncatalog = catalogs->Ncatalog;
 
+  // need to free the place-holder catalogs:
+  for (i = catalogs->Ncatalog; i < catalogs->NCATALOG; i++) {
+    free (catalogs->catalog[i].averageT);
+    free (catalogs->catalog[i].measureT);
+    free (catalogs->catalog[i].secfilt);
+  }
+
   int Nmeasure = 0;
   int Naverage = 0;
@@ -265,4 +276,5 @@
 
   BrightCatalogSplitFree (catalogs);
+  FreeHostTable (table);
 
   return (catalog);
Index: /trunk/Ohana/src/relphot/src/load_images.c
===================================================================
--- /trunk/Ohana/src/relphot/src/load_images.c	(revision 39477)
+++ /trunk/Ohana/src/relphot/src/load_images.c	(revision 39478)
@@ -1,7 +1,9 @@
 # include "relphot.h"
+
+static AstromOffsetTable *table = NULL;
 
 // This function generates a subset of the images based on selections.  Input db has already
 // been loaded with the raw fits table data
-SkyList *load_images (FITS_DB *db, char *regionName, SkyRegion *region) {
+SkyList *load_images (FITS_DB *db, SkyTable *sky, char *regionName, SkyRegion *region) {
 
   Image     *image, *subset;
@@ -10,13 +12,8 @@
   char *inSubset;
 
-  SkyTable *sky = NULL;
   SkyList *skylist = NULL;
 
   INITTIME;
 
-  // load the current sky table (layout of all SkyRegions) 
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
-  SkyTableSetFilenames (sky, CATDIR, "cpt");
-  
   // convert database table to internal structure (binary to Image)
   // 'image' points to the same memory as db->ftable->buffer
@@ -35,5 +32,5 @@
   char mapfile[DVO_MAX_PATH];
   snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.fits", CATDIR);
-  AstromOffsetTable *table = AstromOffsetMapLoad (mapfile, 100000, VERBOSE);
+  table = AstromOffsetMapLoad (mapfile, 100000, VERBOSE);
 
   // assign images.coords.offsetMap -> table->map[i]
@@ -117,4 +114,5 @@
   initMosaics (subset, Nsubset, image, inSubset, Nimage);
   MARKTIME("init mosaics: %f sec\n", dtime);
+  free (inSubset);
   
   // save the subset of images in the static reference in ImageOps, set up indexes
@@ -142,2 +140,8 @@
   return (TRUE);
 }
+
+void free_astrom_table () {
+  if (!table) return;
+  AstromOffsetTableFree (table);
+  free (table);
+}
Index: /trunk/Ohana/src/relphot/src/reload_catalogs.c
===================================================================
--- /trunk/Ohana/src/relphot/src/reload_catalogs.c	(revision 39477)
+++ /trunk/Ohana/src/relphot/src/reload_catalogs.c	(revision 39478)
@@ -152,10 +152,11 @@
     }
     free (image);
-  } else {
-    // load the current sky table (layout of all SkyRegions) 
-    SkyTable *skytable = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
-    // XXX kind of hackish...
-    ALLOCATE (sky, SkyList, 1);
-    strcpy (sky->hosts, skytable->hosts);
+//  } else {
+//    // load the current sky table (layout of all SkyRegions) 
+//    SkyTable *skytable = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
+//    // XXX kind of hackish...
+//    ALLOCATE (sky, SkyList, 1);
+//    strcpy (sky->hosts, skytable->hosts);
+//    SkyTableFree (skytable);
   }
 
@@ -189,4 +190,11 @@
     reload_catalog_parallel_group (&groups[i], sky, imageFile);
   }
+
+  for (i = 0; i < Ngroups; i++) {
+    free (groups[i].hosts);
+  }
+  free (groups);
+  FreeHostTable (table);
+
   return TRUE;
 }
@@ -264,5 +272,8 @@
     fprintf (stderr, "command: %s\n", command);
 
-    if (PARALLEL_MANUAL) continue;
+    if (PARALLEL_MANUAL) { 
+      free (command);
+      continue;
+    }
 
     if (PARALLEL_SERIAL) {
@@ -282,4 +293,5 @@
       group->hosts[i][0].pid = pid; // save for future reference
     }
+    free (command);
   }
 
Index: /trunk/Ohana/src/relphot/src/relphot.c
===================================================================
--- /trunk/Ohana/src/relphot/src/relphot.c	(revision 39477)
+++ /trunk/Ohana/src/relphot/src/relphot.c	(revision 39478)
@@ -2,4 +2,7 @@
 
 int main (int argc, char **argv) {
+
+  SkyTable *sky = NULL;
+  SkyList *skylist = NULL;
 
   // get configuration info, args
@@ -17,5 +20,18 @@
       // take the current set of detections and set the mean magnitudes
       // DOES NOT LOAD THE IMAGE TABLE
-      relphot_objects (0, NULL);
+      sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, TRUE, -1, VERBOSE);
+      if (!sky) {
+	fprintf (stderr, "ERROR running loading sky table from %s\n", CATDIR);
+	exit (2);
+      }
+      SkyTableSetFilenames (sky, CATDIR, "cpt");
+      
+      skylist = SkyListByPatch (sky, -1, &UserPatch);
+      if (!skylist) {
+	fprintf (stderr, "ERROR setting up skylist for %s\n", CATDIR);
+	exit (2);
+      }
+      relphot_objects (sky, skylist, 0, NULL);
+      relphot_free (sky, skylist);
       exit (0);
 
@@ -23,4 +39,5 @@
       // set the mean magnitudes ONLY for SYNPHOT objects
       relphot_synthphot (0, NULL);
+      relphot_free (NULL, NULL);
       exit (0);
 
@@ -28,4 +45,5 @@
       // run image updates in parallel across multiple remote machines
       relphot_parallel_regions ();
+      relphot_free (NULL, NULL);
       exit (0);
 
@@ -33,4 +51,5 @@
       // operation on the remote machines in the PARALLEL_REGION mode
       relphot_parallel_images ();
+      relphot_free (NULL, NULL);
       exit (0);
 
@@ -41,5 +60,20 @@
 	exit (2);
       }
-      reload_catalogs (NULL, NULL, 0, NULL);
+
+      sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, TRUE, -1, VERBOSE);
+      if (!sky) {
+	fprintf (stderr, "ERROR running loading sky table from %s\n", CATDIR);
+	exit (2);
+      }
+      SkyTableSetFilenames (sky, CATDIR, "cpt");
+      
+      skylist = SkyListByPatch (sky, -1, &UserPatch);
+      if (!skylist) {
+	fprintf (stderr, "ERROR setting up skylist for %s\n", CATDIR);
+	exit (2);
+      }
+
+      reload_catalogs (skylist, NULL, 0, NULL);
+      relphot_free (sky, skylist);
       exit (0);
 
Index: /trunk/Ohana/src/relphot/src/relphot_client.c
===================================================================
--- /trunk/Ohana/src/relphot/src/relphot_client.c	(revision 39477)
+++ /trunk/Ohana/src/relphot/src/relphot_client.c	(revision 39478)
@@ -22,16 +22,16 @@
   client_logger_init (HOSTDIR);
 
-  // load the current sky table (layout of all SkyRegions) 
+  // load the current sky table (layout of all SkyRegions) if needed
   SkyTable *sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, TRUE, -1, VERBOSE);
   if (!sky) {
-      fprintf (stderr, "ERROR running loading sky table from %s\n", CATDIR);
-      exit (2);
+    fprintf (stderr, "ERROR running loading sky table from %s\n", CATDIR);
+    exit (2);
   }
   SkyTableSetFilenames (sky, CATDIR, "cpt");
-
+      
   SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch);
   if (!skylist) {
-      fprintf (stderr, "ERROR setting up skylist for %s\n", CATDIR);
-      exit (2);
+    fprintf (stderr, "ERROR setting up skylist for %s\n", CATDIR);
+    exit (2);
   }
   client_logger_message ("loaded sky table and defined patch\n");
@@ -54,5 +54,14 @@
 	  exit (2);
       }
+
+      // free memory associated with the catalogs
+      for (int i = 0; i < Ncatalog; i++) {
+	free_tiny_values (&catalog[i]);
+	dvo_catalog_free (&catalog[i]);
+      }
+      free (catalog);
+      BrightCatalogFree (bcatalog);
       client_logger_message ("generated subset table\n");
+      relphot_client_free (sky, skylist);
       break;
     }
@@ -72,18 +81,16 @@
 
       // load the flat-field correction table from CATDIR
-# if (0)
-      char flatcorrFile[1024];
-      snprintf (flatcorrFile, 1024, "%s/flatcorr.fits", CATDIR);
-      FlatCorrectionTable *flatcorr = FlatCorrectionLoad (flatcorrFile, VERBOSE);
-      client_logger_message ("loaded flat-field correction data\n");
-# endif
       FlatCorrectionTable *flatcorr = NULL;
       reload_catalogs (skylist, flatcorr, HOST_ID, HOSTDIR);
+      freeImages ();
+      free (image);
       client_logger_message ("updated catalogs\n");
+      relphot_client_free (sky, skylist);
       break;
     }
 
     case MODE_UPDATE_OBJECTS: {
-      relphot_objects (HOST_ID, HOSTDIR);
+      relphot_objects (sky, skylist, HOST_ID, HOSTDIR);
+      relphot_client_free (sky, skylist);
       client_logger_message ("updated objects\n");
       break;
@@ -101,5 +108,4 @@
   }
   client_logger_message ("done with relphot_client\n");
-
   exit (0);
 }
Index: /trunk/Ohana/src/relphot/src/relphot_images.c
===================================================================
--- /trunk/Ohana/src/relphot/src/relphot_images.c	(revision 39477)
+++ /trunk/Ohana/src/relphot/src/relphot_images.c	(revision 39478)
@@ -12,7 +12,10 @@
   Catalog *catalog = NULL;
   FITS_DB db;
-  SkyList *skylist = NULL;
 
   INITTIME;
+
+  // load the current sky table (layout of all SkyRegions) 
+  SkyTable *sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
+  SkyTableSetFilenames (sky, CATDIR, "cpt");
 
   /* register database handle with shutdown procedure */
@@ -40,5 +43,5 @@
 
   /* load regions and images based on specified sky patch and/or catalog */
-  skylist = load_images (&db, UserCatalog, &UserPatch);
+  SkyList *skylist = load_images (&db, sky, UserCatalog, &UserPatch);
   MARKTIME("-- load images: %f sec\n", dtime);
 
@@ -219,4 +222,5 @@
       dvo_image_save (&dbX, VERBOSE);
       dvo_image_unlock (&dbX); 
+      gfits_db_free (&dbX);
       MARKTIME("-- save Image.dat.bck: %f sec\n", dtime);
     }
@@ -228,4 +232,5 @@
       dvo_catalog_free (&catalog[i]);
     }
+    free (catalog);
     freeImageBins (Ncatalog, TRUE);
     freeMosaicBins (Ncatalog, TRUE);
@@ -259,5 +264,8 @@
   }
   dvo_image_unlock (&db); 
-
+  gfits_db_free (&db);
+  freeImages();
+
+  relphot_free (sky, skylist);
   exit (0);
 }
Index: /trunk/Ohana/src/relphot/src/relphot_objects.c
===================================================================
--- /trunk/Ohana/src/relphot/src/relphot_objects.c	(revision 39477)
+++ /trunk/Ohana/src/relphot/src/relphot_objects.c	(revision 39478)
@@ -8,19 +8,10 @@
 int relphot_objects_parallel (SkyList *sky);
 
-int relphot_objects (int hostID, char *hostpath) {
+int relphot_objects (SkyTable *sky, SkyList *skylist, int hostID, char *hostpath) {
 
   off_t i, j, k;
   int Nsecfilt;
 
-  SkyTable *sky = NULL;
-  SkyList *skylist = NULL;
   Catalog catalog;
-
-  // load the current sky table (layout of all SkyRegions) 
-  sky = SkyTableLoadOptimal (CATDIR, SKY_TABLE, GSCFILE, TRUE, SKY_DEPTH, VERBOSE);
-  SkyTableSetFilenames (sky, CATDIR, "cpt");
-  
-  // determine the populated SkyRegions overlapping the requested area (default depth)
-  skylist = SkyListByPatch (sky, -1, &UserPatch);
 
   // XXX need to decide how to determine PARALLEL mode...
@@ -112,5 +103,4 @@
     dvo_catalog_free (&catalog);
   }
-  
   return (TRUE);
 }
@@ -169,5 +159,8 @@
     fprintf (stderr, "command: %s\n", command);
 
-    if (PARALLEL_MANUAL) continue;
+    if (PARALLEL_MANUAL) {
+      free (command);
+      continue;
+    }
 
     if (PARALLEL_SERIAL) {
@@ -187,4 +180,5 @@
       table->hosts[i].pid = pid; // save for future reference
     }
+    free (command);
   }
 
@@ -197,4 +191,5 @@
   }
 
+  FreeHostTable (table);
   return TRUE;
 }      
Index: /trunk/Ohana/src/relphot/src/select_images.c
===================================================================
--- /trunk/Ohana/src/relphot/src/select_images.c	(revision 39477)
+++ /trunk/Ohana/src/relphot/src/select_images.c	(revision 39478)
@@ -269,4 +269,7 @@
   REALLOCATE (line_number, off_t, MAX (nimage, 1));
 
+  FREE (RmaxBand);
+  FREE (RminBand);
+
   if (!USE_BASIC_CHECK) {
     free (skycoords);
