Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/FrameCorrection.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/FrameCorrection.c	(revision 37648)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/FrameCorrection.c	(revision 37649)
@@ -160,6 +160,12 @@
 
     // XXX write out an image to represent the correction
-    FrameCorrectionWriteImageSH (frame, "map.dR.fits", TRUE);
-    FrameCorrectionWriteImageSH (frame, "map.dD.fits", FALSE);
+    static int version = 0;
+    char filenameR[1024], filenameD[1024];
+    snprintf (filenameR, 1024, "%s/map.dR.%02d.dat", CATDIR, version);
+    snprintf (filenameD, 1024, "%s/map.dD.%02d.dat", CATDIR, version);
+    version ++;
+
+    FrameCorrectionWriteImageSH (frame, filenameR, TRUE);
+    FrameCorrectionWriteImageSH (frame, filenameD, FALSE);
 
     SHtermsFree (dRc);
@@ -236,6 +242,10 @@
   SHterms *Ylm = SHtermsInit (dRc->lmax);
 
-  FILE *f = fopen ("sh.dat", "w");
+  static int version = 0;
+  char filename[1024];
+  snprintf (filename, 1024, "%s/sh.%02d.dat", CATDIR, version);
+  FILE *f = fopen (filename, "w");
   myAssert (f, "oops");
+  version ++;
 
   for (i = 0; i < Nicrf; i++) {
@@ -612,5 +622,9 @@
   // *** save the icrf points and fit residuals
   { 
-    FILE *f = fopen ("map.dat", "w");
+    static int version = 0;
+    char filename[1024];
+    snprintf (filename, 1024, "%s/map.%02d.dat", CATDIR, version);
+    FILE *f = fopen (filename, "w");
+    version ++;
 
     for (i = 0; i < Npts; i++) {
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/UpdateChips.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/UpdateChips.c	(revision 37648)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/UpdateChips.c	(revision 37649)
@@ -274,4 +274,10 @@
       continue;
     }
+    if (Nraw <= IMFIT_TOO_FEW) {
+      threadinfo->Nskip ++;
+      threadinfo->mode[i] = 0;
+      free (raw);
+      continue;
+    }
 
     /* convert average coordinates to ref entries */
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/bcatalog.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/bcatalog.c	(revision 37648)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/bcatalog.c	(revision 37649)
@@ -63,5 +63,7 @@
   int Nicrf = 0;
 
-  FILE *f = fopen ("test.icrf.dat", "a");
+  char filename[1024];
+  snprintf (filename, 1024, "%s/test.icrf.dat", CATDIR);
+  FILE *f = fopen (filename, "a");
 
   /* exclude stars not in range or with too few measurements */
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/load_catalogs.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/load_catalogs.c	(revision 37648)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/load_catalogs.c	(revision 37649)
@@ -19,4 +19,10 @@
 
   ALLOCATE (catalog, Catalog, skylist[0].Nregions);
+
+  if (subselect && USE_GALAXY_MODEL) {
+    char filename[1024];
+    snprintf (filename, 1024, "%s/test.icrf.dat", CATDIR);
+    unlink (filename);
+  }
 
   // load data from each region file, only use bright stars
Index: /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/relastro_images.c
===================================================================
--- /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/relastro_images.c	(revision 37648)
+++ /branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/relastro_images.c	(revision 37649)
@@ -74,6 +74,9 @@
 	// XXX is is really possible that I do not update the measure.R,D on each loop?? 
 	UpdateObjects (catalog, Ncatalog, (i > 0)); // calculate <R>,<D>; if (i > 0), apply Galaxy Motion Model (if desired)
-	FrameCorrection (catalog, Ncatalog);
-	// if (i > 2) FrameCorrection (catalog, Ncatalog);
+	if ((i > 1) || !USE_GALAXY_MODEL) {
+	  // if GALAXY_MODEL is selected, we want to delay the frame correction until we have 
+	  // applied the galaxy model a couple of times.
+	  FrameCorrection (catalog, Ncatalog);
+	}
 	UpdateChips (catalog, Ncatalog);   // measure.X,Y -> R,D, fit image.coords
 	MARKTIME("update chips: %f sec\n", dtime);
