Index: branches/eam_branches/relphot.20210521/src/TGroupOps.c
===================================================================
--- branches/eam_branches/relphot.20210521/src/TGroupOps.c	(revision 41602)
+++ branches/eam_branches/relphot.20210521/src/TGroupOps.c	(revision 41603)
@@ -853,5 +853,5 @@
       continue;
     }
-    float Mgrid = getMgrid (m, c);
+    float Mgrid = getMgridTiny (&catalog[c].measureT[m]);
     if (isnan(Mgrid)) {
       info->Ngrid ++;
@@ -1013,5 +1013,5 @@
     float Mmos     = getMmos  (m, c);                    // mosaic zero point
 
-    float Mgrid    = getMgrid (m, c);                    // camera offset (deprecated?)
+    float Mgrid    = getMgridTiny (&catalog[c].measureT[m]);                    // camera offset (deprecated?)
     float MrelPSF  = getMrel  (catalog, m, c, MAG_CLASS_PSF, MAG_SRC_CHP); // average magnitude
     float Mflat    = getMflat (m, c, flatcorr, catalog); // flat-field correction
@@ -1124,4 +1124,6 @@
   free (threadinfo);
 
+  // XXX not allocated SetMgrpInfoFree (&summary);
+
   npass_output ++;
 
@@ -1268,5 +1270,7 @@
 
 static float MinMaxChiSq = NAN;
+static float MaxMaxChiSq = 6.0;
 static float MinMaxScatter = NAN;
+static float MaxMaxScatter = 0.1;
 
 void clean_tgroups () {
@@ -1301,10 +1305,10 @@
   float ChiSqUpper90 = stats.Upper90; 
   if (isnan (MinMaxChiSq)) MinMaxChiSq = 2.0*stats.median;
-  float MaxChiSq = MAX (MinMaxChiSq, ChiSqUpper90);
+  float MaxChiSq = MIN(MaxMaxChiSq, MAX (MinMaxChiSq, ChiSqUpper90)); // the upper limit should be between MinMaxChiSq and MaxMaxChiSq 
 
   liststats (slist, NULL, NULL, N, &stats);
   float ScatterUpper90 = stats.Upper90; 
   if (isnan (MinMaxScatter)) MinMaxScatter = 2.0*stats.median;
-  float MaxScatter = MAX (MinMaxScatter, ScatterUpper90);
+  float MaxScatter = MIN(MaxMaxScatter, MAX (MinMaxScatter, ScatterUpper90));
 
   fprintf (stderr, "TGROUPS: Max ChiSq: %f, Max Scatter: %f | ChiSquare Upper 90: %f, Scatter Upper 90: %f\n", MaxChiSq, MaxScatter, ChiSqUpper90, ScatterUpper90);
@@ -1501,5 +1505,5 @@
 
 	float MrelPSF  = getMrel  (catalog, m, c, MAG_CLASS_PSF, MAG_SRC_CHP); // average magnitude
-	// float Mgrid    = getMgrid (m, c);                    // camera offset (deprecated?)
+	// float Mgrid    = getMgridTiny (&catalog[c].measureT[m]); // camera offset (deprecated?)
 	// float Mflat    = getMflat (m, c, flatcorr, catalog); // flat-field correction
 
