Index: /branches/eam_branches/ohana.20170822/src/relphot/src/launch_region_hosts.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/relphot/src/launch_region_hosts.c	(revision 40245)
+++ /branches/eam_branches/ohana.20170822/src/relphot/src/launch_region_hosts.c	(revision 40246)
@@ -58,22 +58,24 @@
     strextend (&command, "-cloud-limit %f", CLOUD_TOLERANCE);
 
-    if (VERBOSE)       	     strextend (&command, "-v");
-    if (VERBOSE2)      	     strextend (&command, "-vv");
-    if (RESET)         	     strextend (&command, "-reset");
-    if (RESET_ZEROPTS) 	     strextend (&command, "-reset-zpts");
-    if (!KEEP_UBERCAL) 	     strextend (&command, "-reset-ubercal");
-    if (DophotSelect)  	     strextend (&command, "-dophot %d", DophotValue);
-    if (ImagSelect)    	     strextend (&command, "-instmag %f %f", ImagMin, ImagMax);
-    if (MaxDensityUse) 	     strextend (&command, "-max-density %f", MaxDensityValue);
-    if (SyntheticPhotometry) strextend (&command, "-synthphot");
-    if (USE_BASIC_CHECK)     strextend (&command, "-basic-image-search");
+    if (VERBOSE)       	     	    strextend (&command, "-v");
+    if (VERBOSE2)      	     	    strextend (&command, "-vv");
+    if (RESET)         	     	    strextend (&command, "-reset");
+    if (RESET_ZEROPTS) 	     	    strextend (&command, "-reset-zpts");
+    if (!KEEP_UBERCAL) 	     	    strextend (&command, "-reset-ubercal");
+    if (DophotSelect)  	     	    strextend (&command, "-dophot %d", DophotValue);
+    if (ImagSelect)    	     	    strextend (&command, "-instmag %f %f", ImagMin, ImagMax);
+    if (MaxDensityUse) 	     	    strextend (&command, "-max-density %f", MaxDensityValue);
+    if (SyntheticPhotometry) 	    strextend (&command, "-synthphot");
+    if (USE_BASIC_CHECK)     	    strextend (&command, "-basic-image-search");
 
-    if (UPDATE)        	     strextend (&command, "-update");
-    if (MOSAIC_ZEROPT) 	     strextend (&command, "-mosaic");
-    if (FREEZE_IMAGES) 	     strextend (&command, "-imfreeze");
-    if (FREEZE_MOSAICS)	     strextend (&command, "-mosfreeze");
-    if (PARALLEL)      	     strextend (&command, "-parallel");
-    if (PARALLEL_MANUAL)     strextend (&command, "-parallel-manual");
-    if (PARALLEL_SERIAL)     strextend (&command, "-parallel-serial");
+    if (UPDATE)        	     	    strextend (&command, "-update");
+    if (MOSAIC_ZEROPT) 	     	    strextend (&command, "-mosaic");
+    if (FREEZE_IMAGES) 	     	    strextend (&command, "-imfreeze");
+    if (FREEZE_MOSAICS)	     	    strextend (&command, "-mosfreeze");
+    if (CALIBRATE_STACKS_AND_WARPS) strextend (&command, "-only-stacks-and-warps");
+
+    if (PARALLEL)      	     	    strextend (&command, "-parallel");
+    if (PARALLEL_MANUAL)     	    strextend (&command, "-parallel-manual");
+    if (PARALLEL_SERIAL)     	    strextend (&command, "-parallel-serial");
 
     // XXX deprecate this if we are happy with the new version
Index: /branches/eam_branches/ohana.20170822/src/relphot/src/liststats.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/relphot/src/liststats.c	(revision 40245)
+++ /branches/eam_branches/ohana.20170822/src/relphot/src/liststats.c	(revision 40246)
@@ -194,5 +194,5 @@
 # define WEIGHT_THRESHOLD 0.3
 
-int fit_least_squares (double *fit, double *y, double *dy, double *wgt, double *wt, int Npts);
+int fit_least_squares (double *fit, double *err, double *y, double *dy, double *wgt, double *wt, int Npts);
 double VectorFractionInterpolate (double *values, float fraction, int Npts);
 double weight_cauchy (double x);
@@ -253,5 +253,5 @@
     
     double oldValue = value;
-    if (!fit_least_squares (&value, dataset->flxlist, dataset->errlist, dataset->wgtlist, dataset->wtvals, Npoints)) {
+    if (!fit_least_squares (&value, NULL, dataset->flxlist, dataset->errlist, dataset->wgtlist, dataset->wtvals, Npoints)) {
       value = oldValue;
       break;
@@ -330,5 +330,5 @@
     }
 
-    if (!fit_least_squares (&value, dataset->ysample, dataset->dysample, dataset->wtsample, NULL, Nkeep)) continue;
+    if (!fit_least_squares (&value, NULL, dataset->ysample, dataset->dysample, dataset->wtsample, NULL, Nkeep)) continue;
 
     dataset->bvalue[Nboot] = value;
@@ -342,9 +342,16 @@
   stats->error = (Shi - Slo) / 2.0;
 
+  // bootstrap can sometimes yield an excessively-optimistic result for the error.  Do not let
+  // the reported error be smaller than the formal error 
+  double errvalue;
+  if (fit_least_squares (&value, &errvalue, dataset->ykeep, dataset->dykeep, dataset->wtkeep, NULL, Nkeep)) {
+    stats->error = MAX (stats->error, errvalue);
+  }
+
   return TRUE;
 }
 
 // wgt is externally-supplied weight, wt is optional
-int fit_least_squares (double *fit, double *y, double *dy, double *wgt, double *wt, int Npts) { 
+int fit_least_squares (double *fit, double *err, double *y, double *dy, double *wgt, double *wt, int Npts) { 
 
   int i;
@@ -364,5 +371,6 @@
   }
   if (S0 == 0.0) return FALSE;
-  *fit = S1 / S0;
+  *fit = S1  / S0;
+  if (err) { *err = 1.0 / S0; }
   return TRUE;
 }
Index: /branches/eam_branches/ohana.20170822/src/relphot/src/relphot_images.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/relphot/src/relphot_images.c	(revision 40245)
+++ /branches/eam_branches/ohana.20170822/src/relphot/src/relphot_images.c	(revision 40246)
@@ -42,5 +42,5 @@
   MARKTIME("-- load images: %f sec\n", dtime);
 
-  checkImages("load images");
+  // checkImages("load images");
 
   /* unlock, if we can (else, unlocked below) */
@@ -48,4 +48,5 @@
 
   // load the flat correction table (if defined)
+  // we no longer need to do this: the flatcorrection is now saved in measure.Mflat
 # if (0)
   char flatcorrfile[256];
@@ -62,5 +63,5 @@
     /* add in a loop over the catalogs calling dvo_catalog_chipcoords */
 
-    checkImages("load catalog");
+    // checkImages("load catalog");
 
     /* match measurements with images, mosaics */
@@ -81,5 +82,5 @@
 
     setExclusions (catalog, Ncatalog, TRUE);
-    checkImages("set Exclu");
+    // checkImages("set Exclu");
 
     global_stats (catalog, Ncatalog, flatcorr, 0);
@@ -114,9 +115,9 @@
       }
       if (VERBOSE2) dumpMags (stderr, catalog, Ncatalog);
-      checkImages("start loop");
+      // checkImages("start loop");
 
       setMrel  (catalog, Ncatalog, flatcorr); // threaded
       if (VERBOSE2) dumpMags (stderr, catalog, Ncatalog);
-      checkImages("set Mrel");
+      // checkImages("set Mrel");
 
       if (PLOTSTUFF) {
@@ -124,5 +125,5 @@
       }
       setMcal  (catalog, FALSE, flatcorr);
-      checkImages("set Mcal");
+      // checkImages("set Mcal");
       if (VERBOSE2) dumpMags (stderr, catalog, Ncatalog);
 
Index: /branches/eam_branches/ohana.20170822/src/relphot/src/relphot_parallel_images.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/relphot/src/relphot_parallel_images.c	(revision 40245)
+++ /branches/eam_branches/ohana.20170822/src/relphot/src/relphot_parallel_images.c	(revision 40246)
@@ -36,7 +36,4 @@
   client_logger_message ("loaded images\n");
 
-  // once we have read this table, we should remove it for repeat runs
-  // unlink (IMAGE_TABLE); // XXX a bit risky, add some protection?
-
   makeMosaics (image, Nimage, TRUE);
 
@@ -44,4 +41,5 @@
 
   // load the flat correction table (if defined)
+  // we no longer need to do this: the flatcorrection is now saved in measure.Mflat
 # if (0)
   char flatcorrfile[256];
@@ -150,7 +148,8 @@
   client_logger_message ("all hosts are done the loops\n");
 
-  /* set Mcal & Mmos for bad images */
-  setMcal  (catalog, TRUE, flatcorr);
-  setMmos  (catalog, TRUE, flatcorr);
+  /* set Mcal & Mmos for bad images (for stack_and_warps, force images to be measured) */
+  int onlyPoorImages = !CALIBRATE_STACKS_AND_WARPS;
+  setMcal  (catalog, onlyPoorImages, flatcorr);
+  setMmos  (catalog, onlyPoorImages, flatcorr);
   MARKTIME("-- finalize Mcal values: %f sec\n", dtime);
 
Index: /branches/eam_branches/ohana.20170822/src/relphot/src/setMrelCatalog.c
===================================================================
--- /branches/eam_branches/ohana.20170822/src/relphot/src/setMrelCatalog.c	(revision 40245)
+++ /branches/eam_branches/ohana.20170822/src/relphot/src/setMrelCatalog.c	(revision 40246)
@@ -569,4 +569,5 @@
 
     float psfQFbest = 0.0;
+    float SNbest = 0.0;
 
     off_t stackBestMeasure = -1;
