diff --git a/src/interpret.c b/src/interpret.c
index 73837899a2dc929e4a45c82e12cf0bac1a6bc769..8d076ff5f20254ce7404aa38e3020cc35e78388d 100644
--- a/src/interpret.c
+++ b/src/interpret.c
@@ -4,7 +4,7 @@
 ||| See the files COPYING and DISCLAIMER for more information.
 \*/
 #include "global.h"
-RCSID("$Id: interpret.c,v 1.57 1998/01/13 22:56:43 hubbe Exp $");
+RCSID("$Id: interpret.c,v 1.58 1998/01/14 07:53:52 hubbe Exp $");
 #include "interpret.h"
 #include "object.h"
 #include "program.h"
@@ -1531,7 +1531,7 @@ void mega_apply(enum apply_type type, INT32 args, void *arg1, void *arg2)
       
       if(fun<0)
       {
-	pop_n_elems(args);
+	pop_n_elems(sp-save_sp);
 	push_int(0);
 	return;
       }
diff --git a/src/program.c b/src/program.c
index c4d2e1a18bc92e0c24d8d03fd31d5ff40b3b14a0..275188c71aef24ea35d3574ae021cbda628fae30 100644
--- a/src/program.c
+++ b/src/program.c
@@ -4,7 +4,7 @@
 ||| See the files COPYING and DISCLAIMER for more information.
 \*/
 #include "global.h"
-RCSID("$Id: program.c,v 1.48 1998/01/13 22:56:49 hubbe Exp $");
+RCSID("$Id: program.c,v 1.49 1998/01/14 07:53:52 hubbe Exp $");
 #include "program.h"
 #include "object.h"
 #include "dynamic_buffer.h"
@@ -697,12 +697,33 @@ if((char *)(p->X) < (char *)p || (char *)(p->X)> ((char *)p)+size) fatal("Progra
 
 struct program *end_first_pass(int finish)
 {
+  int e;
   struct program *prog;
+  struct pike_string *s;
+
+  MAKE_CONSTANT_SHARED_STRING(s,"__INIT");
+
+
+  /* Collect references to inherited __INIT functions */
+  for(e=1;e<new_program->num_inherits;e++)
+  {
+    int id;
+    if(new_program->inherits[e].inherit_level!=1) continue;
+    id=low_reference_inherited_identifier(e, s);
+    if(id!=-1)
+    {
+      init_node=mknode(F_ARG_LIST,
+		       init_node,
+		       mkcastnode(void_type_string,
+				  mkapplynode(mkidentifiernode(id),0)));
+    }
+  }
 
   /*
    * Define the __INIT function, but only if there was any code
    * to initialize.
    */
+
   if(init_node)
   {
     union idptr tmp;
@@ -965,20 +986,6 @@ void do_inherit(struct svalue *prog,
     fun.id_flags |= ID_INHERITED;
     add_to_identifier_references(fun);
   }
-
-  /* Ska det h{r vara s} h{r? */
-  s=findstring("__INIT");
-  if(s)
-  {
-    if(-1 != find_shared_string_identifier(s,p))
-    {
-      e=reference_inherited_identifier(0, s);
-      init_node=mknode(F_ARG_LIST,
-		       init_node,
-		       mkcastnode(void_type_string,
-				  mkapplynode(mkidentifiernode(e),0)));
-    }
-  }
 }
 
 void simple_do_inherit(struct pike_string *s,