Index: trunk/psphot/src/psphotApResid.c
===================================================================
--- trunk/psphot/src/psphotApResid.c	(revision 6056)
+++ trunk/psphot/src/psphotApResid.c	(revision 6379)
@@ -1,3 +1,4 @@
 # include "psphot.h"
+static char DEFAULT_OPTION[] = "SKYBIAS";
 
 // measure the aperture residual statistics
@@ -69,5 +70,5 @@
     // APTREND options : NONE SKYBIAS XY_LIN XY_QUAD SKY_XY_LIN FULL 
     char *ApTrendOption = psMetadataLookupPtr (&status, config, "APTREND");
-    if (!status) ApTrendOption = psStringCopy ("SKYBIAS");
+    if (!status) ApTrendOption = DEFAULT_OPTION;
 
     // 3hi/1lo sigma clipping on the rflux vs metric fit
@@ -190,18 +191,4 @@
 	psf->ApTrend  = psVectorChiClipFitPolynomial4D (psf->ApTrend, stats, mask, PSFTRY_MASK_ALL, apResid, dMag, xPos, yPos, r2rflux, flux);
     }
-
-# if (1)
-    psPolynomial4D *poly = psf->ApTrend;
-    for (int nt = 0; nt <= poly->nT; nt++) {
-	for (int nz = 0; nz <= poly->nZ; nz++) {
-	    for (int ny = 0; ny <= poly->nY; ny++) {
-		for (int nx = 0; nx <= poly->nX; nx++) {
-		    if (poly->mask[nx][ny][nz][nt]) continue;
-		    fprintf (stderr, "%d %d %d %d : %22.15g\n", nx, ny, nz, nt, poly->coeff[nx][ny][nz][nt]);
-		}
-	    }
-	}
-    }
-# endif
 
     // construct the fitted values and the residuals
@@ -256,9 +243,16 @@
 	      1e6*psf->ApTrend->coeff[0][2][0][0]);
 
-    // psFree (stats);
-    // psFree (mask);
-    // psFree (rflux);
-    // psFree (apResid);
-
+    psFree (mask);
+    psFree (xPos);
+    psFree (yPos);
+    psFree (flux);
+    psFree (r2rflux);
+    psFree (apResid);
+    psFree (dMag);
+
+    psFree (fit);
+    psFree (resid);
+    psFree (stats);
+    psFree (residStats);
     return true;
 }
