diff --git a/src/docode.c b/src/docode.c
index 80b397cfb00e0ac4ffc579b5afc9c3c0c028e377..8d78e520f0e9e91d4fc4954a29a7b9c33d670301 100644
--- a/src/docode.c
+++ b/src/docode.c
@@ -4,7 +4,7 @@
 ||| See the files COPYING and DISCLAIMER for more information.
 \*/
 #include "global.h"
-RCSID("$Id: docode.c,v 1.40 1998/10/09 23:30:21 hubbe Exp $");
+RCSID("$Id: docode.c,v 1.41 1998/11/16 22:14:49 hubbe Exp $");
 #include "las.h"
 #include "program.h"
 #include "language.h"
@@ -534,6 +534,14 @@ static int do_docode2(node *n,int flags)
 
     tmp2=do_docode(CAR(n),DO_NOT_COPY);
     emit2(F_CONST0);
+#ifdef DEBUG
+    /* This is really ugly because there is always a chance that the bug
+     * will disappear when new instructions are added to the code, but
+     * think it is worth it.
+     */
+    if(d_flag)
+      emit2(F_MARK);
+#endif
     tmp3=do_jump(F_BRANCH,-1);
     tmp1=ins_label(-1);
     DO_CODE_BLOCK(CDR(n));
@@ -542,6 +550,11 @@ static int do_docode2(node *n,int flags)
     do_jump(n->token,tmp1);
     ins_label(current_break);
 
+#ifdef DEBUG
+    if(d_flag)
+      emit2(F_POP_MARK);
+#endif
+
     current_switch_jumptable = prev_switch_jumptable;
     current_break=break_save;
     current_continue=continue_save;
@@ -563,6 +576,14 @@ static int do_docode2(node *n,int flags)
     current_continue=alloc_label();
 
     tmp2=do_docode(CAR(n),0);
+#ifdef DEBUG
+    /* This is really ugly because there is always a chance that the bug
+     * will disappear when new instructions are added to the code, but
+     * think it is worth it.
+     */
+    if(d_flag)
+      emit2(F_MARK);
+#endif
     tmp3=do_jump(F_BRANCH,-1);
     tmp1=ins_label(-1);
 
@@ -571,6 +592,10 @@ static int do_docode2(node *n,int flags)
     emit(F_LABEL,tmp3);
     do_jump(n->token,tmp1);
     ins_label(current_break);
+#ifdef DEBUG
+    if(d_flag)
+      emit2(F_POP_MARK);
+#endif
 
     current_switch_jumptable = prev_switch_jumptable;
     current_break=break_save;
diff --git a/src/interpret.c b/src/interpret.c
index 3b3d5197a3823d6cc80c12a771916f7bec7b0bd6..23c77a1fb5d816abc046e788c3d941b1c85aadb4 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.98 1998/11/13 01:28:43 hubbe Exp $");
+RCSID("$Id: interpret.c,v 1.99 1998/11/16 22:14:50 hubbe Exp $");
 #include "interpret.h"
 #include "object.h"
 #include "program.h"
@@ -547,6 +547,9 @@ static int eval_instruction(unsigned char *pc)
 
       if(recoveries && sp-evaluator_stack < recoveries->sp)
 	fatal("Stack error (underflow).\n");
+
+      if(mark_sp > mark_stack && mark_sp[-1] > sp)
+	fatal("Stack error (underflow?)\n");
       
       if(d_flag > 9) do_debug();
 
@@ -1209,6 +1212,7 @@ static int eval_instruction(unsigned char *pc)
       CASE(F_MARK2); *(mark_sp++)=sp;
       CASE(F_MARK); *(mark_sp++)=sp; break;
       CASE(F_MARK_X); *(mark_sp++)=sp-GET_ARG(); break;
+      CASE(F_POP_MARK); --mark_sp; break;
 
       CASE(F_CLEAR_STRING_SUBTYPE);
       if(sp[-1].type==T_STRING) sp[-1].subtype=0;
diff --git a/src/language.yacc b/src/language.yacc
index 33772dc4ac5ab6619fc79a24089ce354389a5563..0533afb5a1557af681568601f98555cfce1ea076 100644
--- a/src/language.yacc
+++ b/src/language.yacc
@@ -11,8 +11,8 @@
 %token F_OFFSET
 %token F_PREFIX_256 F_PREFIX_512 F_PREFIX_768 F_PREFIX_1024
 %token F_PREFIX_CHARX256 F_PREFIX_WORDX256 F_PREFIX_24BITX256
-%token F_POP_VALUE F_POP_N_ELEMS F_MARK F_MARK2 F_MARK_X F_LDA
-%token F_CALL_LFUN F_CALL_LFUN_AND_POP F_CALL_LFUN_AND_RETURN
+%token F_POP_VALUE F_POP_N_ELEMS F_MARK F_MARK2 F_MARK_X F_POP_MARK
+%token F_LDA F_CALL_LFUN F_CALL_LFUN_AND_POP F_CALL_LFUN_AND_RETURN
 %token F_APPLY F_APPLY_AND_POP F_MARK_APPLY F_MARK_APPLY_POP
 %token F_APPLY_AND_RETURN F_MARK_AND_STRING
 %token F_APPLY_ASSIGN_LOCAL F_APPLY_ASSIGN_LOCAL_AND_POP
@@ -179,7 +179,7 @@
 /* This is the grammar definition of Pike. */
 
 #include "global.h"
-RCSID("$Id: language.yacc,v 1.106 1998/11/11 22:19:48 grubba Exp $");
+RCSID("$Id: language.yacc,v 1.107 1998/11/16 22:14:52 hubbe Exp $");
 #ifdef HAVE_MEMORY_H
 #include <memory.h>
 #endif
diff --git a/src/lex.c b/src/lex.c
index ce73a9702ed5157943344c3e600ddac0219c15fb..39766b8e5c6becc3f291d5227a029467e7cf02fd 100644
--- a/src/lex.c
+++ b/src/lex.c
@@ -4,7 +4,7 @@
 ||| See the files COPYING and DISCLAIMER for more information.
 \*/
 #include "global.h"
-RCSID("$Id: lex.c,v 1.56 1998/10/09 17:56:32 hubbe Exp $");
+RCSID("$Id: lex.c,v 1.57 1998/11/16 22:14:53 hubbe Exp $");
 #include "language.h"
 #include "array.h"
 #include "lex.h"
@@ -176,6 +176,7 @@ struct keyword instr_names[]=
 { "mark sp-X",          F_MARK_X, I_HASARG },
 { "mark",               F_MARK },
 { "mark mark",          F_MARK2 },
+{ "pop mark",           F_POP_MARK },
 { "negative number",	F_NEG_NUMBER, I_HASARG },
 { "number",             F_NUMBER, I_HASARG },
 { "pop",		F_POP_VALUE },