Index: /trunk/Ohana/src/libdvo/src/skyregion_io.c
===================================================================
--- /trunk/Ohana/src/libdvo/src/skyregion_io.c	(revision 5955)
+++ /trunk/Ohana/src/libdvo/src/skyregion_io.c	(revision 5956)
@@ -72,5 +72,5 @@
   if (f == (FILE *) NULL) { 
     fprintf (stderr, "cannot open %s for output\n", filename);
-    exit (1);
+    return (FALSE);
   }
   
@@ -111,5 +111,5 @@
   if (sky == NULL) {
     fprintf (stderr, "error loading sky table\n");
-    exit (1);
+    return (NULL);
   }
   /* set the depths to the default depth */
@@ -119,5 +119,6 @@
   sprintf (filename, "%s/SkyTable.fits", catdir);
   check_file_access (filename, FALSE, verbose);
-  SkyTableSave (sky, filename);
+  if (!SkyTableSave (sky, filename)) return NULL;
+
   fits_convert_SkyRegion (sky[0].regions, sizeof (SkyTable), sky[0].Nregions);
   return (sky);
@@ -128,5 +129,5 @@
   if (sky == NULL) {
     fprintf (stderr, "error loading sky table\n");
-    exit (1);
+    return (NULL);
   }
 
@@ -134,5 +135,6 @@
   sprintf (filename, "%s/SkyTable.fits", catdir);
   check_file_access (filename, FALSE, verbose);
-  SkyTableSave (sky, filename);
+  if (!SkyTableSave (sky, filename)) return NULL;
+
   fits_convert_SkyRegion (sky[0].regions, sizeof (SkyRegion), sky[0].Nregions);
   return (sky);
Index: /trunk/Ohana/src/libdvo/src/skyregion_ops.c
===================================================================
--- /trunk/Ohana/src/libdvo/src/skyregion_ops.c	(revision 5955)
+++ /trunk/Ohana/src/libdvo/src/skyregion_ops.c	(revision 5956)
@@ -51,4 +51,5 @@
   ALLOCATE (list, SkyList, 1);
   ALLOCATE (list[0].regions,  SkyRegion *, NREGIONS);
+  ALLOCATE (list[0].filename,  char *, NREGIONS);
   list[0].Nregions = N;
 
@@ -71,9 +72,8 @@
 
     list[0].regions[N] = &region[No];
+    list[0].filename[N] = table[0].filename[No];
     N++;
-    if (N == NREGIONS) {
-      NREGIONS += 10;
-      REALLOCATE (list[0].regions, SkyRegion *, NREGIONS);
-    }      
+    CHECK_REALLOCATE (list[0].regions, SkyRegion *, NREGIONS, N, 10);
+    CHECK_REALLOCATE (list[0].filename, char *, NREGIONS, N, 10);
     list[0].Nregions = N;
 
@@ -167,7 +167,9 @@
     extra = SkyListChildrenByBounds (table, -1, depth, Rmin, 360.0, Dmin, Dmax);
     REALLOCATE (list[0].regions, SkyRegion *, list[0].Nregions + extra[0].Nregions);
+    REALLOCATE (list[0].filename, char *, list[0].Nregions + extra[0].Nregions);
     Ns = list[0].Nregions;
     for (i = 0; i < extra[0].Nregions; i++) {
       list[0].regions[i + Ns] = extra[0].regions[i];
+      list[0].filename[i + Ns] = extra[0].filename[i];
     }
     list[0].Nregions += extra[0].Nregions;
@@ -192,4 +194,5 @@
   ALLOCATE (list, SkyList, 1);
   ALLOCATE (list[0].regions, SkyRegion *, NNEW);
+  ALLOCATE (list[0].filename, char *, NNEW);
 
   region = table[0].regions;
@@ -221,7 +224,9 @@
 	NNEW = Nnew + children[0].Nregions + 50;
 	REALLOCATE (list[0].regions, SkyRegion *, NNEW);
+	REALLOCATE (list[0].filename, char *, NNEW);
       }
       for (j = 0; j < children[0].Nregions; j++) {
 	list[0].regions[Nnew + j] = children[0].regions[j];
+	list[0].filename[Nnew + j] = children[0].filename[j];
       }
       Nnew += children[0].Nregions;
@@ -229,6 +234,8 @@
     } else {
       list[0].regions[Nnew] = &region[i];
+      list[0].filename[Nnew] = table[0].filename[i];
       Nnew ++;
       CHECK_REALLOCATE (list[0].regions, SkyRegion *, NNEW, Nnew, 50);
+      CHECK_REALLOCATE (list[0].filename, char *, NNEW, Nnew, 50);
     }
   }
