Index: branches/eam_branches/ipp-20120905/Ohana/src/delstar/Makefile
===================================================================
--- branches/eam_branches/ipp-20120905/Ohana/src/delstar/Makefile	(revision 34692)
+++ branches/eam_branches/ipp-20120905/Ohana/src/delstar/Makefile	(revision 34693)
@@ -29,4 +29,5 @@
 $(SRC)/delete_imagename.$(ARCH).o \
 $(SRC)/delete_imagefile.$(ARCH).o \
+$(SRC)/delete_image_photcodes.$(ARCH).o \
 $(SRC)/delete_photcodes.$(ARCH).o \
 $(SRC)/delete_times.$(ARCH).o 	  \
Index: branches/eam_branches/ipp-20120905/Ohana/src/delstar/include/delstar.h
===================================================================
--- branches/eam_branches/ipp-20120905/Ohana/src/delstar/include/delstar.h	(revision 34692)
+++ branches/eam_branches/ipp-20120905/Ohana/src/delstar/include/delstar.h	(revision 34693)
@@ -93,5 +93,6 @@
 void SortAveMeasMatch (off_t *MEAS, off_t *AVE, off_t N);
 
-int delete_photcodes (SkyList *skylist, int hostID, char *hostpath);
+int delete_photcodes (int hostID, char *hostpath);
 int delete_photcodes_parallel (SkyList *sky);
 int delete_photcodes_catalog (Catalog *catalog, PhotCode **photcodes, int Nphotcodes);
+int delete_image_photcodes (FITS_DB *db);
Index: branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delete_image_photcodes.c
===================================================================
--- branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delete_image_photcodes.c	(revision 34692)
+++ branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delete_image_photcodes.c	(revision 34693)
@@ -1,8 +1,8 @@
 # include "delstar.h"
 
-void delete_image_photcodes (FITS_DB *db) {
+int delete_image_photcodes (FITS_DB *db) {
 
   off_t i, j;
-  off_t  Nimage, Noutimage;
+  off_t  Nimage;
   Image *image;
   Image *outimage;
@@ -19,5 +19,5 @@
 
   /* delete the identified images */
-  int Noutimage = 0;
+  off_t Noutimage = 0;
   ALLOCATE (outimage, Image, Nimage);
   for (i = 0; i < Nimage; i++) {
@@ -32,5 +32,5 @@
   free (image);
   
-  if (VERBOSE) fprintf (stderr, "removing "OFF_T_FMT" images (leaving "OFF_T_FMT" of "OFF_T_FMT")\n",  Noutimage - Nimage, Noutimage, Nimage);
+  if (VERBOSE) fprintf (stderr, "removing "OFF_T_FMT" images (leaving "OFF_T_FMT" of "OFF_T_FMT")\n",  Nimage - Noutimage, Noutimage, Nimage);
   // gfits_table_set_Image (&db[0].ftable, outimage, Noutimage);
 
@@ -40,8 +40,7 @@
   db[0].ftable.buffer = (char *) outimage;
 
-  dvo_image_save (db, VERBOSE);
-  dvo_image_unlock (db);
+  if (!dvo_image_save (db, VERBOSE)) return FALSE;
+  if (!dvo_image_unlock (db)) return FALSE;
 
-  fprintf (stderr, "SUCCESS\n");
-  exit (0);
+  return TRUE;
 }
Index: branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delete_photcodes.c
===================================================================
--- branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delete_photcodes.c	(revision 34692)
+++ branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delete_photcodes.c	(revision 34693)
@@ -1,8 +1,22 @@
 # include "delstar.h"
 
-int delete_photcodes (SkyList *skylist, int hostID, char *hostpath) {
+int delete_photcodes (int hostID, char *hostpath) {
 
   int i;
   Catalog catalog;
+
+  // load the current sky table (layout of all SkyRegions) 
+  SkyTable *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 *skylist = SkyListByPatch (sky, -1, &UserPatch);
+  if (!skylist) {
+    fprintf (stderr, "ERROR setting up skylist for %s\n", CATDIR);
+    exit (2);
+  }
 
   // launch the remote jobs
Index: branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delstar.c
===================================================================
--- branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delstar.c	(revision 34692)
+++ branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delstar.c	(revision 34693)
@@ -29,22 +29,11 @@
       break;
     case MODE_PHOTCODES: {
-      delete_image_photcodes (&db);
+      if (!delete_image_photcodes (&db)) exit (1);
 
-      // load the current sky table (layout of all SkyRegions) 
-      SkyTable *sky = SkyTableLoadOptimal (CATDIR, NULL, NULL, TRUE, -1, VERBOSE);
-      if (!sky) {
-	  fprintf (stderr, "ERROR running loading sky table from %s\n", CATDIR);
-	  exit (2);
+      if (!delete_photcodes (0, NULL)) {
+	fprintf (stderr, "failure deleting measurements\n");
+	exit (1);
       }
-      SkyTableSetFilenames (sky, CATDIR, "cpt");
-
-      SkyList *skylist = SkyListByPatch (sky, -1, &UserPatch);
-      if (!skylist) {
-	  fprintf (stderr, "ERROR setting up skylist for %s\n", CATDIR);
-	  exit (2);
-      }
-
-      delete_photcodes (skylist, 0, NULL);
-      break;
+      exit (0);
     }
     case MODE_ORPHAN:
Index: branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delstar_client.c
===================================================================
--- branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delstar_client.c	(revision 34692)
+++ branches/eam_branches/ipp-20120905/Ohana/src/delstar/src/delstar_client.c	(revision 34693)
@@ -32,5 +32,5 @@
       break;
     case MODE_PHOTCODES:
-      delete_photcodes (skylist, HOST_ID, HOSTDIR);
+      delete_photcodes (HOST_ID, HOSTDIR);
       break;
     case MODE_ORPHAN:
