Index: /trunk/psphot/src/psphotApResid.c
===================================================================
--- /trunk/psphot/src/psphotApResid.c	(revision 5951)
+++ /trunk/psphot/src/psphotApResid.c	(revision 5952)
@@ -59,5 +59,21 @@
     stats->clipIter = 3;
 
+    // first clip out objects which are too far from the median 
+    stats->clipIter = 1;
+    maskToConstant (psf->ApTrend);
+    psf->ApTrend  = psVectorClipFitPolynomial3D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, NULL, xPos, yPos, rflux);
+
+    // next, fit just SkyBias and clip out objects which are too far from the median 
+    stats->clipIter = 2;
+    maskToSkyBias (psf->ApTrend);
+    psf->ApTrend  = psVectorClipFitPolynomial3D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, NULL, xPos, yPos, rflux);
+
+    // finally, fit x, y, SkyBias and clip out objects which are too far from the median 
+    stats->clipIter = 2;
+    maskToDefault (psf->ApTrend);
+    psf->ApTrend  = psVectorClipFitPolynomial3D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, NULL, xPos, yPos, rflux);
+
     // linear clipped fit of apResid to rflux, xPos, yPos
+    # if (0)
     psf->ApTrend  = psVectorClipFitPolynomial3D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, NULL, xPos, yPos, rflux);
     psf->skyBias  = psf->ApTrend->coeff[0][0][1] / (M_PI * PS_SQR(RADIUS));
@@ -65,4 +81,5 @@
     psf->dApResid = stats->sampleStdev;
     psf->ApTrend->coeff[0][0][1] = 0;
+    # endif
 
     /*
