Index: trunk/Ohana/src/relphot/src/relphot_objects.c
===================================================================
--- trunk/Ohana/src/relphot/src/relphot_objects.c	(revision 39608)
+++ trunk/Ohana/src/relphot/src/relphot_objects.c	(revision 39609)
@@ -149,6 +149,8 @@
     char *moddate = ohana_sec_to_date (now.tv_sec);
     gfits_modify (&catalog.header, "RELPHOT", "%s", 1, moddate);      
-    snprintf (history, 128, "repair warp measure.imageID: %s", moddate);
-    gfits_modify_alt (&catalog.header, "HISTORY", "%S", 0, history); // adds a new entry
+    if (REPAIR_WARPS) {
+      snprintf (history, 128, "repair warp measure.imageID: %s", moddate);
+      gfits_modify_alt (&catalog.header, "HISTORY", "%S", 0, history); // adds a new entry
+    }
     free (moddate);
 
Index: trunk/Ohana/src/relphot/src/select_images.c
===================================================================
--- trunk/Ohana/src/relphot/src/select_images.c	(revision 39608)
+++ trunk/Ohana/src/relphot/src/select_images.c	(revision 39609)
@@ -34,4 +34,6 @@
 
   INITTIME;
+
+  // FILE *ftest = fopen ("image.region.dat", "w");
 
   // the comparison is made in the catalog local projection. below we set crval1,2
@@ -166,4 +168,6 @@
     }
 
+    // fprintf (ftest, "%f %f : %f %f : %d %d\n", RminImage, RmaxImage, DminImage, DmaxImage, timage[i].tzero, timage[i].photcode);
+
     // check that this image is even in range of the searched region
     if (DminImage > DmaxSkyRegion) continue;
@@ -272,4 +276,6 @@
   }
   MARKTIME("\nfinish image selection: %f sec\n", dtime);
+
+  // fclose (ftest);
 
   if (VERBOSE) fprintf (stderr, "found "OFF_T_FMT" images\n", nimage);
Index: trunk/Ohana/src/relphot/src/setMrelCatalog.c
===================================================================
--- trunk/Ohana/src/relphot/src/setMrelCatalog.c	(revision 39608)
+++ trunk/Ohana/src/relphot/src/setMrelCatalog.c	(revision 39609)
@@ -706,4 +706,13 @@
     }
 
+    // stack measurement used for 'best' was a detection (not forced from the other bands)
+    if ((measure[k].photFlags2 & 0x00000004) == 0) {
+      secfilt[Nsec].flags |= ID_SECF_STACK_BESTDET;
+    }
+    // stack measurement used for 'primary' was a detection (not forced from the other bands)
+    if ((stackPrimaryMeasure >= 0) && ((measure[stackPrimaryMeasure].photFlags2 & 0x00000004) == 0)) {
+      secfilt[Nsec].flags |= ID_SECF_STACK_PRIMDET;
+    }
+
     secfilt[Nsec].flags |= ID_SECF_HAS_PS1_STACK;
   } // Nsecfilt loop
