Index: /tags/ipp-ps1-20211104/psModules/src/objects/pmSourceIO.h
===================================================================
--- /tags/ipp-ps1-20211104/psModules/src/objects/pmSourceIO.h	(revision 41911)
+++ /tags/ipp-ps1-20211104/psModules/src/objects/pmSourceIO.h	(revision 41912)
@@ -95,4 +95,6 @@
 bool pmSourceIO_WriteGhosts (psFits *fits, pmFPA *fpa, pmConfig *config);
 
+void 		  pmSourceChipBoundsCleanup (void);
+
 /// @}
 # endif /* PM_SOURCE_IO_H */
Index: /tags/ipp-ps1-20211104/psModules/src/objects/pmSourceIO_CMF.c.in
===================================================================
--- /tags/ipp-ps1-20211104/psModules/src/objects/pmSourceIO_CMF.c.in	(revision 41911)
+++ /tags/ipp-ps1-20211104/psModules/src/objects/pmSourceIO_CMF.c.in	(revision 41912)
@@ -485,8 +485,10 @@
     if (!psFitsWriteTableNew(fits, header, table, extname)) {
         psError(psErrorCodeLast(), false, "writing ext data %s\n", extname);
+        psFree(tableColumns);
         psFree(table);
         psFree(header);
         return false;
     }
+    psFree(tableColumns);
     psFree(table);
     psFree(header);
Index: /tags/ipp-ps1-20211104/psModules/src/objects/pmSourceIO_Ghosts.c
===================================================================
--- /tags/ipp-ps1-20211104/psModules/src/objects/pmSourceIO_Ghosts.c	(revision 41911)
+++ /tags/ipp-ps1-20211104/psModules/src/objects/pmSourceIO_Ghosts.c	(revision 41912)
@@ -57,8 +57,4 @@
 
 # include "pmSourceInternal.h"
-static psVector *chipXmin = NULL;
-static psVector *chipXmax = NULL;
-static psVector *chipYmin = NULL;
-static psVector *chipYmax = NULL;
 
 # define ESCAPE(MSG) { \
@@ -243,6 +239,6 @@
 
                         //do a rudimentary check of whether the ghost is on the pixel FPA
-                        if (abs(ghost->FP->y) > 21000.)  continue;
-                        if (abs(ghost->FP->x) > 21000.)  continue;
+                        if (abs(ghost->FP->y) > 21000.)  { psFree (ghost); continue; }
+                        if (abs(ghost->FP->x) > 21000.)  { psFree (ghost); continue; }
 
                         //save the ghost positions
@@ -267,7 +263,5 @@
  			    psArrayAdd (table, 100, row);
  			    psFree (row);
-						
- 			}
- 			else {
+ 			} else {
  			    psMetadata *row = psMetadataAlloc ();
  			    psMetadataAdd (row, PS_LIST_TAIL, "X_STAR_FPA",     PS_DATA_F32,    "x coord on focal plane",	  ref->FP->x);
@@ -290,5 +284,5 @@
  			    psFree (row);
  			}		  
- 						
+			psFree (ghost);
  		    }
  		}
@@ -366,4 +360,15 @@
 }
 
+static psVector *chipXmin = NULL;
+static psVector *chipXmax = NULL;
+static psVector *chipYmin = NULL;
+static psVector *chipYmax = NULL;
+
+void pmSourceChipBoundsCleanup (void) {
+    psFree (chipXmin);
+    psFree (chipXmax);
+    psFree (chipYmin);
+    psFree (chipYmax);
+}
 
 bool pmSourceChipBounds (pmFPA *fpa) {
Index: /tags/ipp-ps1-20211104/psModules/src/objects/pmSourceInternal.h
===================================================================
--- /tags/ipp-ps1-20211104/psModules/src/objects/pmSourceInternal.h	(revision 41911)
+++ /tags/ipp-ps1-20211104/psModules/src/objects/pmSourceInternal.h	(revision 41912)
@@ -55,4 +55,3 @@
 bool              pmSourceExtractFreeChipBounds(void);
 
-
 #endif
