diff --git a/lib/master.pike.in b/lib/master.pike.in
index 65e9d41e81d0448bd1c98416510c85aba3d6def3..0f64454dc190f227074dd2cd7900db9f33b61ec1 100644
--- a/lib/master.pike.in
+++ b/lib/master.pike.in
@@ -1,4 +1,4 @@
-/* $Id: master.pike.in,v 1.34 1998/10/17 02:10:00 grubba Exp $
+/* $Id: master.pike.in,v 1.35 1998/10/22 09:11:43 hubbe Exp $
  * 
  * Master-file for Pike.
  *
@@ -213,7 +213,7 @@ static program low_findprog(string pname, string ext)
     case ".pike":
       if(array s2=master_file_stat(fname+".o"))
       {	
-	if(s2[1]>=0 && s2[2]>=s[2])
+	if(s2[1]>=0 && s2[3]>=s[3])
 	{
 	  mixed err=catch {
 	    return decode_value(_static_modules.files()->Fd(fname+".o","r")->read(),Codec());
diff --git a/src/Makefile.in b/src/Makefile.in
index 8f049d3e8c76dcd8c502ed136a700a1017120fe3..5f1c536a431e4ab6f920e1e1485825ed0fc08812 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1,5 +1,5 @@
 #
-# $Id: Makefile.in,v 1.120 1998/09/29 16:51:03 grubba Exp $
+# $Id: Makefile.in,v 1.121 1998/10/22 09:12:25 hubbe Exp $
 #
 
 # This line is needed on some machines.
@@ -202,6 +202,7 @@ interpret.o: $(SRCDIR)/interpret.c
 
 force :
 
+
 # install
 install: pike hilfe pike-module aclocal
 	@echo
@@ -294,6 +295,7 @@ install: pike hilfe pike-module aclocal
 	    if [ -f "$(share_prefix)/$$f" ]; then \
 	      mv -f "$(share_prefix)/$$f" "$(share_prefix)/$$f.old"; \
 	    else : ; fi; \
+	    rm -f "$(share_prefix)/$$f.o" >/dev/null 2>/dev/null ; \
 	    if [ -f "$(lib_prefix)/$$f" ]; then \
               if test "x$(lib_prefix)" != "x$(share_prefix)"; then \
 	        mv -f "$(lib_prefix)/$$f" "$(lib_prefix)/$$f.now_in_share.old"; \
@@ -312,6 +314,7 @@ install: pike hilfe pike-module aclocal
 	    if [ -f "$(lib_prefix)/$$f" ]; then \
 	      mv -f "$(lib_prefix)/$$f" "$(lib_prefix)/$$f.old"; \
 	    else : ; fi; \
+	    rm -f "$(lib_prefix)/$$f.o" >/dev/null 2>/dev/null ; \
 	    cp "$(TMP_LIBDIR)/$$f" "$(lib_prefix)/$$f" || exit 1; \
 	    chmod a+r "$(lib_prefix)/$$f"; \
 	    chmod u+w "$(lib_prefix)/$$f"; \
@@ -334,6 +337,14 @@ install: pike hilfe pike-module aclocal
 	  done ; \
 	else : ; fi
 
+optimize:
+	$(exec_prefix)/pike -m ./dumpmaster.pike $(lib_prefix)/master.pike
+	( \
+	  find $(lib_prefix)/modules -type f \( -name '*.pmod' -o -name '*.pike' \) -print  ; \
+	  find $(share_prefix)/modules -type f \( -name '*.pmod' -o -name '*.pike' \) -print \
+	) | \
+	while read file ; do $(exec_prefix)/pike ./dumpmodule.pike $$file ; done
+
 # tidy up a bit
 tidy:
 	-rm -f *.o core y.output y.tab.c y.tab.h
diff --git a/src/dumpmaster.pike b/src/dumpmaster.pike
new file mode 100644
index 0000000000000000000000000000000000000000..b0be71dac80f1e7fbdc4f570a37cf714c522bd2b
--- /dev/null
+++ b/src/dumpmaster.pike
@@ -0,0 +1,26 @@
+#define UNDEFINED (([])[0])
+
+void handle_error(mixed err)
+{
+  werror("%O\n",err);
+}
+program compile_file(string file)
+{
+  return compile(cpp(_static_modules.files()->Fd(file,"r")->read(),file));
+}
+
+class Codec
+{
+  string nameof(string x)
+  {
+    if(mixed tmp=search(all_constants(),x))  return tmp;
+    return UNDEFINED;
+  } 
+}
+void _main(string *argv, string *env)
+{
+  program p=compile_file(argv[-1]);
+  string s=encode_value(p, Codec());
+  _static_modules.files()->Fd(argv[-1] + ".o","wct")->write(s);
+  exit(0);
+}
diff --git a/src/dumpmodule.pike b/src/dumpmodule.pike
new file mode 100755
index 0000000000000000000000000000000000000000..d15ccf51d5e14799f1472e9fe3cffef762c32584
--- /dev/null
+++ b/src/dumpmodule.pike
@@ -0,0 +1,131 @@
+#!/usr/local/bin/pike
+
+program p;
+
+#define error(X) throw( ({ (X), backtrace()[0..sizeof(backtrace())-2] }) )
+class Codec
+{
+  string nameof(mixed x)
+  {
+//    werror("%O\n",x);
+    if(p!=x)
+      if(mixed tmp=search(all_constants(),x))
+	return "efun:"+tmp;
+
+    switch(sprintf("%t",x))
+    {
+      case "program":
+	if(p!=x)
+	{
+	  if(mixed tmp=search(master()->programs,x))
+	    return tmp;
+#if 0
+	  if(mixed tmp=search(values(_static_modules), x)!=-1)
+	  {
+	    return "_static_modules."+(indices(_static_modules)[tmp]);
+	  }
+#endif
+	}
+	break;
+
+      case "object":
+	if(p!=x)
+	  if(mixed tmp=search(master()->objects,x))
+	    if(tmp=search(master()->programs,tmp))
+	      return tmp;
+	break;
+    }
+    return ([])[0];
+  } 
+
+  function functionof(string x)
+  {
+    if(sscanf(x,"efun:%s",x))
+      return all_constants()[x];
+
+    werror("Failed to decode %s\n",x);
+    return 0;
+  }
+
+
+  object objectof(string x)
+  {
+    if(sscanf(x,"efun:%s",x))
+      return all_constants()[x];
+
+    if(object tmp=(object)x) return tmp;
+    werror("Failed to decode %s\n",x);
+    return 0;
+    
+  }
+
+  program programof(string x)
+  {
+    if(sscanf(x,"efun:%s",x))
+      return all_constants()[x];
+
+    if(sscanf(x,"_static_modules.%s",x))
+    {
+      return (program)_static_modules[x];
+    }
+
+    if(program tmp=(program)x) return tmp;
+    werror("Failed to decode %s\n",x);
+    return 0;
+  }
+
+  mixed encode_object(object x)
+  {
+    error("Cannot encode objects yet.\n");
+  }
+
+
+  mixed decode_object(object x)
+  {
+    error("Cannot encode objects yet.\n");
+  }
+}
+
+int main(int argc, string *argv)
+{
+  foreach(argv[1..],string file)
+    {
+      werror(file +": ");
+      mixed err=catch {
+	if(mixed s=file_stat(file))
+	{
+	  if(s[1]<=0)
+	  {
+	    werror("is a directory or special file.\n");
+	    break;
+	  }
+	}else{
+	  werror("does not exist.\n");
+	  break;
+	}
+	if(programp(p=compile_file(file)))
+	{
+	  string s=encode_value(p, Codec());
+	  p=decode_value(s,Codec());
+	  if(programp(p))
+	  {
+	    Stdio.File(file + ".o","wct")->write(s);
+	    werror("dumped.\n");
+	  }else{
+	    werror("Decode failed.\n");
+	  }
+	}else{
+	  werror("Compilation failed.\n");
+	}
+      };
+      if(err)
+      {
+#ifdef ERRORS
+	err[0]="While dumping "+file+": "+err[0];
+	werror(master()->describe_backtrace(err));
+#else
+	werror(err[0]);
+#endif
+      }
+    }
+}
diff --git a/src/pike-module.in b/src/pike-module.in
index 8fc99459d20247d0bb08874de568304bccc6bc52..ca22175fd796834a56da3cc32cde3517e0fd873f 100644
--- a/src/pike-module.in
+++ b/src/pike-module.in
@@ -2,6 +2,7 @@
 
 // Source directory
 string srcdir;
+string pike="�pike�";
 string prefix="�prefix�";
 string lib_prefix="�lib_prefix�";
 string share_prefix="�share_prefix�";
@@ -95,10 +96,15 @@ int main(int argc, string *argv)
     ({"make",Getopt.NO_ARG,({"--make"}) }),
     ({"auto",Getopt.NO_ARG,({"--auto"}) }),
     ({"source",Getopt.HAS_ARG,({"--source"}) }),
+    ({"query",Getopt.HAS_ARG,({"--query"}) }),
     )),array opt)
     {
       switch(opt[0])
       {
+	case "query":
+	  write("%s\n",this_object()[opt[1]]);
+	  exit(0);
+
 	case "fixate":
 	  string file=Stdio.read_file(opt[1]);
 	  break;