Index: trunk/magic/remove/src/warpedpixels.c
===================================================================
--- trunk/magic/remove/src/warpedpixels.c	(revision 21156)
+++ trunk/magic/remove/src/warpedpixels.c	(revision 21438)
@@ -22,8 +22,10 @@
     int n = psArrayLength(skycells);
 
-    psRegion     bounds = *pmChipPixels(sf->chip);
+    psRegion     *bounds = pmChipPixels(sf->chip);
     
-    int width  = bounds.x1 - bounds.x0;
-    int height = bounds.y1 - bounds.y0;
+    int width  = bounds->x1 - bounds->x0;
+    int height = bounds->y1 - bounds->y0;
+
+    psFree(bounds);
 
     sf->warpedPixels = psImageAlloc(width, height, PS_TYPE_U8);
@@ -35,4 +37,5 @@
 
         addTouchedPixels(sf, resolved_name);
+        psFree(resolved_name);
     }
 
@@ -48,4 +51,5 @@
         psFitsWriteImage(fits, header, sf->warpedPixels, 0, NULL);
         psFitsClose(fits);
+        psFree(header);
     }
     return true;
@@ -62,4 +66,5 @@
     }
     psMetadata *header = psFitsReadHeader(NULL, fits);
+    psFitsClose(fits);
     if (!header) {
         psError(PS_ERR_IO, false, "failed to read fixts header from skycell file: %s", fileName);
@@ -75,4 +80,6 @@
     int naxis2 = psMetadataLookupS32(NULL, header, "NAXIS2");
 
+    psFree(header);
+
     /* now set up our wrapper to the chip astrometry to apply to the whole chip */
     sf->astrom = streakSetAstrometry(sf->astrom, sf->stage, sf->inAstrom->fpa, sf->chip, false, NULL, 
@@ -111,4 +118,6 @@
         pt[i].y = p.y;
     }
+
+    psFree(wcs);
 
     // put the corners in the desired order (see comments below)
