Index: branches/eam_branches/ipp-20120905/Ohana/src/relphot/src/StarOps.c
===================================================================
--- branches/eam_branches/ipp-20120905/Ohana/src/relphot/src/StarOps.c	(revision 34423)
+++ branches/eam_branches/ipp-20120905/Ohana/src/relphot/src/StarOps.c	(revision 34424)
@@ -327,5 +327,7 @@
 
   char *primaryCell = NULL;
-  ALLOCATE (primaryCell, char, DVO_MAX_PATH);
+  if (isSetMrelFinal) {
+    ALLOCATE (primaryCell, char, DVO_MAX_PATH);
+  }
 
   for (j = 0; j < catalog[Nc].Naverage; j++) {
@@ -338,5 +340,7 @@
     }
 
-    BoundaryTreePrimaryCell(primaryCell, catalog[Nc].average[j].R, catalog[Nc].average[j].D);
+    if (isSetMrelFinal) {
+      BoundaryTreePrimaryCell(primaryCell, catalog[Nc].average[j].R, catalog[Nc].average[j].D);
+    }
 
     int GoodPS1 = FALSE;
@@ -432,5 +436,10 @@
 	    // count the extended detections
 	    if (!isnan(catalog[Nc].measure[m].Map)) {
-	      if (catalog[Nc].measure[m].M - catalog[Nc].measure[m].Map > 0.5) {
+	      float dMagAp = catalog[Nc].measure[m].M - catalog[Nc].measure[m].Map;
+	      float SigmaAp = hypot(0.1, 2.5*catalog[Nc].measure[m].dM);
+	      // XXX this is still quite ad hoc, but at least it:
+	      // (a) converges to 0.1 mag offset at the bright end
+	      // (b) converges to 0.5 mag offset at the faint end (dM = 0.2)
+	      if (dMagAp > SigmaAp) {
 		Next ++;
 		NextPS1 ++;
@@ -660,13 +669,13 @@
 	  case 0:
 	    catalog[Nc].secfilt[Nsecfilt*j+Nsec].flags |= ID_PHOTOM_PASS_0;
-	    GoodPS1 = TRUE;
+	    if (havePS1) GoodPS1 = TRUE;
 	    break;
 	  case 1:
 	    catalog[Nc].secfilt[Nsecfilt*j+Nsec].flags |= ID_PHOTOM_PASS_1;
-	    GoodPS1 = TRUE;
+	    if (havePS1) GoodPS1 = TRUE;
 	    break;
 	  case 2:
 	    catalog[Nc].secfilt[Nsecfilt*j+Nsec].flags |= ID_PHOTOM_PASS_2;
-	    GoodPS1 = TRUE;
+	    if (havePS1) GoodPS1 = TRUE;
 	    break;
 	  case 3:
@@ -693,8 +702,9 @@
 
     if (isSetMrelFinal) {
-      DVOAverageFlags flagBits = ID_OBJ_EXT | ID_OBJ_EXT_ALT | ID_OBJ_GOOD | ID_OBJ_GOOD_ALT;
-
-      // we attempt to set a few flags here; reset those bits before trying:
-      catalog[Nc].average[j].flags &= ~flagBits;
+      if (pass == 0) {
+	DVOAverageFlags flagBits = ID_OBJ_EXT | ID_OBJ_EXT_ALT | ID_OBJ_GOOD | ID_OBJ_GOOD_ALT;
+	// we attempt to set a few flags here; reset those bits before trying:
+	catalog[Nc].average[j].flags &= ~flagBits;
+      }
 
       if (NextPS1 && (NextPS1 > NpsfPS1)) {
Index: branches/eam_branches/ipp-20120905/Ohana/src/relphot/src/initialize.c
===================================================================
--- branches/eam_branches/ipp-20120905/Ohana/src/relphot/src/initialize.c	(revision 34423)
+++ branches/eam_branches/ipp-20120905/Ohana/src/relphot/src/initialize.c	(revision 34424)
@@ -77,5 +77,21 @@
   args_client (argc, argv);
 
-  if (MODE == MODE_UPDATE_OBJECTS) return;
+  if (MODE == MODE_UPDATE_OBJECTS) {
+    char tmpline1[256];
+    int Ns;
+    Nphotcodes = GetPhotcodeNsecfilt ();
+    ALLOCATE (photcodes, PhotCode *, Nphotcodes);
+    ALLOCATE (PhotcodeList, char, 256);
+    for (Ns = 0; Ns < Nphotcodes; Ns++) {
+      photcodes[Ns] = GetPhotcodebyNsec (Ns);
+      if (Ns > 0) {
+	snprintf (tmpline1, 256, "%s,%s", PhotcodeList, photcodes[Ns][0].name);
+      } else {
+	snprintf (tmpline1, 256, "%s", photcodes[Ns][0].name);
+      }
+      strcpy (PhotcodeList, tmpline1);
+    }
+    return;
+  }
 
   // load the list of photcodes into the globals (photcodes, Nphotcodes)
