Index: trunk/Ohana/src/addstar/src/FilterStars.c
===================================================================
--- trunk/Ohana/src/addstar/src/FilterStars.c	(revision 28967)
+++ trunk/Ohana/src/addstar/src/FilterStars.c	(revision 29001)
@@ -1,5 +1,3 @@
 # include "addstar.h"
-#include "pslib/psMetadata.h"
-#include "psmodules/pmSourceMasks.h"
 # define EXTERNAL_ID TRUE
 
Index: trunk/Ohana/src/addstar/src/LoadData.c
===================================================================
--- trunk/Ohana/src/addstar/src/LoadData.c	(revision 28967)
+++ trunk/Ohana/src/addstar/src/LoadData.c	(revision 29001)
@@ -80,4 +80,8 @@
 	 
     inStars = ReadStarsFITS (f, headers[Nhead], headers[Ndata], &images[0][Nvalid].nstar);
+    if (!inStars) {
+      // XXX need to free the data here or in ReadStarsFITS on error
+      continue;
+    }
     inStars = FilterStars (inStars, &images[0][Nvalid], Nvalid, options);
     *stars = MergeStars (*stars, Nstars, inStars, images[0][Nvalid].nstar);
Index: trunk/Ohana/src/addstar/src/ReadStarsFITS.c
===================================================================
--- trunk/Ohana/src/addstar/src/ReadStarsFITS.c	(revision 28967)
+++ trunk/Ohana/src/addstar/src/ReadStarsFITS.c	(revision 29001)
@@ -49,5 +49,5 @@
   if (stars == NULL) {
     fprintf (stderr, "ERROR: invalid table type %s\n", type);
-    exit (1);
+    return (NULL);
   }
   // Nstars is not necessarily == *nstars (The former is the number of detections, the
@@ -69,4 +69,8 @@
   swapped = FALSE;
   smpdata = gfits_table_get_SMPData (table, &Nstars, &swapped);
+  if (!smpdata) {
+    fprintf (stderr, "skipping inconsistent entry\n");
+    return (NULL);
+  }
   ZeroPt = GetZeroPoint();
 
@@ -108,4 +112,8 @@
 
   ps1data = gfits_table_get_PS1_DEV_0 (table, &Nstars, NULL);
+  if (!ps1data) {
+    fprintf (stderr, "skipping inconsistent entry\n");
+    return (NULL);
+  }
   ZeroPt = GetZeroPoint();
 
@@ -153,4 +161,8 @@
 
   ps1data = gfits_table_get_PS1_DEV_1 (table, &Nstars, NULL);
+  if (!ps1data) {
+    fprintf (stderr, "skipping inconsistent entry\n");
+    return (NULL);
+  }
   ZeroPt = GetZeroPoint();
 
@@ -212,4 +224,8 @@
 
   ps1data = gfits_table_get_CMF_PS1_V1 (table, &Nstars, NULL);
+  if (!ps1data) {
+    fprintf (stderr, "skipping inconsistent entry\n");
+    return (NULL);
+  }
   ZeroPt = GetZeroPoint();
 
@@ -284,4 +300,8 @@
 
   ps1data = gfits_table_get_CMF_PS1_V1_Alt (table, &Nstars, NULL);
+  if (!ps1data) {
+    fprintf (stderr, "skipping inconsistent entry\n");
+    return (NULL);
+  }
   ZeroPt = GetZeroPoint();
 
@@ -348,4 +368,8 @@
 
   ps1data = gfits_table_get_CMF_PS1_V2 (table, &Nstars, NULL);
+  if (!ps1data) {
+    fprintf (stderr, "skipping inconsistent entry\n");
+    return (NULL);
+  }
   ZeroPt = GetZeroPoint();
 
Index: trunk/Ohana/src/addstar/src/find_matches_refstars.c
===================================================================
--- trunk/Ohana/src/addstar/src/find_matches_refstars.c	(revision 28967)
+++ trunk/Ohana/src/addstar/src/find_matches_refstars.c	(revision 29001)
@@ -218,5 +218,5 @@
     }
 
-    N = N1[i];
+    N = i;
     if (stars[N][0].found > -1) continue;
     if (!IN_REGION (stars[N][0].average.R, stars[N][0].average.D)) continue;
@@ -286,5 +286,5 @@
 
     for (j = 0; j < NREFSTAR_GROUP; j++) {
-      N = N1[i + j];
+      N = i + j;
 
       catalog[0].measure[Nmeas]          = stars[N][0].measure;
Index: trunk/Ohana/src/addstar/test/dvomerge.dvo
===================================================================
--- trunk/Ohana/src/addstar/test/dvomerge.dvo	(revision 28967)
+++ trunk/Ohana/src/addstar/test/dvomerge.dvo	(revision 29001)
@@ -95,5 +95,5 @@
     subset T = t if (id == imageID[$i])
     set dT = T - time[$i]
-    vstat -q dT 
+    vstat dT 
     tapOK {abs($MEAN)  < 0.00001} "time for measure ID $i (MEAN)"
     tapOK {abs($SIGMA) < 0.00001} "time for measure ID $i (SIGMA)"
