Index: trunk/psLib/src/fits/psFits.c
===================================================================
--- trunk/psLib/src/fits/psFits.c	(revision 12549)
+++ trunk/psLib/src/fits/psFits.c	(revision 12555)
@@ -7,6 +7,6 @@
  *  @author Robert DeSonia, MHPCC
  *
- *  @version $Revision: 1.63 $ $Name: not supported by cvs2svn $
- *  @date $Date: 2007-03-22 21:40:47 $
+ *  @version $Revision: 1.64 $ $Name: not supported by cvs2svn $
+ *  @date $Date: 2007-03-23 00:34:52 $
  *
  *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
@@ -65,6 +65,6 @@
             return false;
         }
-    }
-
+	fits->fd = NULL;
+    }
     return true;
 }
@@ -72,5 +72,9 @@
 static void fitsFree(psFits* fits)
 {
-    (void)fitsClose(fits);
+    if (!fits) return;
+    if (fits->fd) {
+	fitsClose(fits);
+    }
+    psFree (fits->extword);
 }
 
@@ -84,5 +88,4 @@
 
     bool status = fitsClose(fits);
-    psMemSetDeallocator(fits,NULL);
     psFree(fits);
 
@@ -205,5 +208,4 @@
     PS_ASSERT_PTR_NON_NULL(extword, false);
 
-    int status = 0;
     int hdutype = 0;
     char name[MAX_STRING_LENGTH];
@@ -212,4 +214,6 @@
     for (int i = 1; true; i++) {
 	// are we able to read the next HDU?
+
+	int status = 0;
 	if (fits_movabs_hdu(fits->fd, i, &hdutype, &status)) {
 	    char fitsErr[MAX_STRING_LENGTH];
@@ -220,6 +224,7 @@
 	    return false;
 	}
-	// is there a keyword called 'extword'?
-	if (fits_read_key_str(fits->fd, (char *)extword, name, NULL, &status)) {
+	// is there a keyword called 'extword'? (read as string regardless of type)
+	status = 0;
+	if (fits_read_keyword(fits->fd, (char *)extword, name, NULL, &status)) {
 	    continue;
 	}
