Index: trunk/psastro/src/psastroLoadRefstars.c
===================================================================
--- trunk/psastro/src/psastroLoadRefstars.c	(revision 15256)
+++ trunk/psastro/src/psastroLoadRefstars.c	(revision 15257)
@@ -54,4 +54,5 @@
     // psStringAppend (&getstarCommand, " -D CATMODE mef -maglim %f -region %f %f %f %f -o %s", MAGmax, RAmin, DECmin, RAmax, DECmax, tempFile);
     // XXX TEST : no magnitude limit
+    // XXX need to specify the desired photometry system
     psStringAppend (&getstarCommand, " -D CATMODE mef -region %f %f %f %f -o %s", RAmin, DECmin, RAmax, DECmax, tempFile);
     psTrace ("psastro", 3, "%s\n", getstarCommand);
@@ -77,25 +78,12 @@
 
     psTimerStart ("psastro");
-    psMetadata *header = psFitsReadHeader (NULL, fits);
-    psArray *table = psFitsReadTable (fits);
-    psFitsClose (fits);
-
-    unlink (tempFile);
-
-    if (table == NULL) {
-        psError(PSASTRO_ERR_REFSTARS, true, "failure to load astrometric reference\n");
-        return NULL;
-    }
-
-    psLogMsg ("psastro", 3, "read getstar output table : %f sec\n", psTimerMark ("psastro"));
+    long numSources = psFitsTableSize(fits); // Number of sources in table
 
     // convert the Average table to the pmAstromObj entries
-    psTimerStart ("psastro");
-
-    psArray *refstars = psArrayAllocEmpty (table->n);
-    for (int i = 0; i < table->n; i++) {
+    psArray *refstars = psArrayAllocEmpty (numSources);
+    for (int i = 0; i < numSources; i++) {
         pmAstromObj *ref = pmAstromObjAlloc ();
 
-        psMetadata *row = table->data[i];
+        psMetadata *row = psFitsReadTableRow(fits, i); // Table row
 
         // DVO tables are stored in degrees
@@ -112,11 +100,13 @@
         psArrayAdd (refstars, 100, ref);
         psFree (ref);
+        psFree (row);
     }
-    psFree (header);
-    psFree (table);
-    psLogMsg ("psastro", 3, "converted table to pmAstromObj : %f sec\n", psTimerMark ("psastro"));
+    psLogMsg ("psastro", 3, "loaded %ld reference stars : %f sec\n", refstars->n, psTimerMark ("psastro"));
 
     psTrace ("psastro", 3, "loaded %ld reference stars from (%10.6f,%10.6f) - (%10.6f,%10.6f)\n",
              refstars->n, RAmin, DECmin, RAmax, DECmax);
+
+    psFitsClose (fits);
+    unlink (tempFile);
 
     // dump or plot the available refstars
