Index: /trunk/psModules/src/camera/pmFPAfileIO.c
===================================================================
--- /trunk/psModules/src/camera/pmFPAfileIO.c	(revision 17988)
+++ /trunk/psModules/src/camera/pmFPAfileIO.c	(revision 17989)
@@ -629,5 +629,5 @@
       case PM_FPA_FILE_ASTROM_MODEL:
       case PM_FPA_FILE_ASTROM_REFSTARS:
-        psTrace ("psModules.camera", 5, "NOT freeing %s (%s) : save for further analysis\n", file->filename, file->name);
+        psTrace ("psModules.camera", 6, "NOT freeing %s (%s) : save for further analysis\n", file->filename, file->name);
         return true;
       case PM_FPA_FILE_JPEG:
@@ -779,36 +779,37 @@
         file->fits->options = psMemIncrRefCounter(file->options);
 
-        // in most cases, we have already open and read the phu and determined the format.
-        // in some cases, (eg DetDB images), we have only just determined the filename.
-        // we need to check the file format before we can work with the file
-        if (!file->format) {
-          psMetadata *phu = psFitsReadHeader (NULL, file->fits);
-          if (!phu) {
-            psError(PS_ERR_IO, false, "Failed to read file header %s\n", file->filename);
-            return false;
-          }
-
-          // determine the current format from the header
-          // determine camera if not specified already
-          file->format = pmConfigCameraFormatFromHeader (config, phu, true);
-          if (!file->format) {
-            psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", file->filename);
-            psFree(phu);
-            return false;
-          }
-          psFree(phu);
-        }
-
-        // if needed, set the optional EXTWORD field based on the camera value
-        psMetadata *fileMenu = psMetadataLookupMetadata (NULL, file->format, "FILE");
-        if (!fileMenu) {
-          psError (PS_ERR_IO, true, "FILE METADATA missing from camera format %s\n",
-                   config->formatName);
-          return false;
-        }
-        char *extword = psMetadataLookupStr (&status, fileMenu, "EXTWORD");
-        if (status) {
-          psFitsSetExtnameWord (file->fits, extword);
-        }
+	// in most cases, we have already open and read the phu and determined the format.
+	// in some cases, (eg DetDB images), we have only just determined the filename.
+	// we need to check the file format before we can work with the file
+	if (!file->format) {
+	  psMetadata *phu = psFitsReadHeader (NULL, file->fits);
+	  if (!phu) {
+	    psError(PS_ERR_IO, false, "Failed to read file header %s\n", file->filename);
+	    return false;
+	  }
+
+	  // determine the current format from the header
+	  // determine camera if not specified already
+	  // XXX can I actually reach this with camera not specified??
+	  file->format = pmConfigCameraFormatFromHeader (NULL, NULL, config, phu, true);
+	  if (!file->format) {
+	    psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", file->filename);
+	    psFree(phu);
+	    return false;
+	  }
+	  psFree(phu);
+	}
+
+	// if needed, set the optional EXTWORD field based on the camera value
+	psMetadata *fileMenu = psMetadataLookupMetadata (NULL, file->format, "FILE");
+	if (!fileMenu) {
+	  psError (PS_ERR_IO, true, "FILE METADATA missing from camera format %s\n",
+		   config->formatName);
+	  return false;
+	}
+	char *extword = psMetadataLookupStr (&status, fileMenu, "EXTWORD");
+	if (status) {
+	  psFitsSetExtnameWord (file->fits, extword);
+	}
 
         // XXX these are probably only needed for WRITE files
@@ -849,5 +850,7 @@
 
 // for this file and view, if we need to read a PHU, read it.  return true for any non-error
-// condition. this function should be called by pmFPAfileOpen.
+// condition. this function should be called by pmFPAfileOpen.  this function is only called
+// for files for which the PHU is not already loaded (files passed via the db or files after
+// the first in a multifile dataset)
 bool pmFPAfileReadPHU (pmFPAfile *file, const pmFPAview *view, pmConfig *config)
 {
@@ -885,7 +888,6 @@
     psMetadata *phu = psFitsReadHeader (NULL, file->fits);
     if (!file->format) {
-        // XXX do we need to read the recipe here?  these files are supplemental, and probably
-        // do not need to re-load the recipes
-        file->format = pmConfigCameraFormatFromHeader (config, phu, false);
+	// determine the format (camera is already known); do not load the recipe
+        file->format = pmConfigCameraFormatFromHeader (NULL, &file->formatName, config, phu, false);
         if (!file->format) {
             psError(PS_ERR_IO, false, "Failed to read CCD format from %s\n", file->filename);
@@ -893,6 +895,4 @@
             return false;
         }
-        file->formatName = psStringCopy(config->formatName);
-
     } else {
         bool valid;
