Index: /branches/eam_branches/ipp-20130904/psModules/src/objects/pmSourceIO_CMF.c.in
===================================================================
--- /branches/eam_branches/ipp-20130904/psModules/src/objects/pmSourceIO_CMF.c.in	(revision 36268)
+++ /branches/eam_branches/ipp-20130904/psModules/src/objects/pmSourceIO_CMF.c.in	(revision 36269)
@@ -1064,7 +1064,11 @@
         // EXT_MODEL_TYPE gives the model chosen by psphot as the best.
         // Putting this into the XFIT table makes 3 copies of it (one for each model)
-        // but since we have fewer XFIT rows than psf rows that is cheaper than putting it
+        // but since we have many fewer XFIT rows than psf rows that is cheaper than putting it
         // in the psf table.
         psS32 extModelType = psMetadataLookupS32(&status, row, "EXT_MODEL_TYPE");
+        if (!status) {
+            // older cmfs don't have this column
+            extModelType = -1;
+        }
 
         psEllipseAxes axes;
@@ -1095,20 +1099,21 @@
         model->covar = covar;
 
-        psArrayAdd(source->modelFits, 1, model);
-        psFree(model);
-
         if (modelType == extModelType) {
             // The software that created this source picked this model as the best of the fits. 
             // Set the extModel to point to it.
+            // This is important for programs like psastro (skycal) so that its output cmfs
+            // will have valid EXT_MODEL_TYPE
             psFree(source->modelEXT);
             source->modelEXT = psMemIncrRefCounter(model);
+            source->type = PM_SOURCE_TYPE_EXTENDED;
             if (0) {
-                // since FLAGS were read we shouldn't need to do this.
-                source->type = PM_SOURCE_TYPE_EXTENDED;
+                // since FLAGS were read we don't need to do this
                 source->mode |= PM_SOURCE_MODE_EXTMODEL;
-                source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT;   // XXX: Is this safe?
+                source->mode |= PM_SOURCE_MODE_NONLINEAR_FIT;
             }
         }
 
+        psArrayAdd(source->modelFits, 1, model);
+        psFree(model);
         psFree(row);
     }
