diff --git a/src/main.c b/src/main.c
index 9e205c284891fe56cfa249a5b6ffa4652eeaddf6..18a346861fa6329f3090c8f0c7cdb015375c5772 100644
--- a/src/main.c
+++ b/src/main.c
@@ -5,7 +5,7 @@
 \*/
 /**/
 #include "global.h"
-RCSID("$Id: main.c,v 1.146 2002/01/27 18:25:43 mast Exp $");
+RCSID("$Id: main.c,v 1.147 2002/05/13 22:14:05 mast Exp $");
 #include "fdlib.h"
 #include "backend.h"
 #include "module.h"
@@ -810,6 +810,7 @@ void low_exit_main(void)
   exit_cpp();
   cleanup_interpret();
   cleanup_added_efuns();
+  cleanup_module_support();
   exit_operators();
   exit_iterators();
   cleanup_program();
diff --git a/src/module_support.c b/src/module_support.c
index a53f5b97c7c35bdd5aebdd3ff7fb62ad3a3fa844..1e42a9ac3b857c365805d80cefeed54595bcfb84 100644
--- a/src/module_support.c
+++ b/src/module_support.c
@@ -11,7 +11,7 @@
 
 #define sp Pike_sp
 
-RCSID("$Id: module_support.c,v 1.43 2002/05/11 00:29:57 nilsson Exp $");
+RCSID("$Id: module_support.c,v 1.44 2002/05/13 22:14:04 mast Exp $");
 
 /* Checks that args_to_check arguments are OK.
  * Returns 1 if everything worked ok, zero otherwise.
@@ -373,7 +373,6 @@ PMOD_EXPORT void get_all_args(char *fname, INT32 args, char *format,  ... )
  */
    
 static struct mapping *exported_symbols;
-static struct program *function_encapsulation_program;
 
 PMOD_EXPORT void pike_module_export_symbol(char *name,
 					   int len,
@@ -424,3 +423,13 @@ PMOD_EXPORT void *pike_module_import_symbol(char *name,
   free_string(str);
   return 0;
 }
+
+#ifdef DO_PIKE_CLEANUP
+void cleanup_module_support (void)
+{
+  if (exported_symbols) {
+    free_mapping (exported_symbols);
+    exported_symbols = NULL;
+  }
+}
+#endif
diff --git a/src/module_support.h b/src/module_support.h
index 299e33dfff16482ea16940e6c3df6a4fe0e4b981..9113758af7f62bff286aa5dc2dbe1117a117ccd1 100644
--- a/src/module_support.h
+++ b/src/module_support.h
@@ -5,7 +5,7 @@
 \*/
 
 /*
- * $Id: module_support.h,v 1.9 2002/01/16 02:54:15 nilsson Exp $
+ * $Id: module_support.h,v 1.10 2002/05/13 22:14:04 mast Exp $
  */
 #ifndef MODULE_SUPPORT_H
 #include <stdarg.h>
@@ -50,6 +50,7 @@ PMOD_EXPORT void *pike_module_import_symbol(char *str,
 					    int len,
 					    char *module,
 					    int module_len);
+void cleanup_module_support (void);
 /* Prototypes end here */
 
 #endif