diff -ruN klic-3.003-2002-03-08a/include/klic/susp.h klic-3.003-2002-03-08b/include/klic/susp.h
--- klic-3.003-2002-03-08a/include/klic/susp.h	Fri Jan 18 15:37:50 2002
+++ klic-3.003-2002-03-08b/include/klic/susp.h	Fri Mar  8 20:10:33 2002
@@ -55,10 +55,10 @@
   initnewsusp(temp, (var), (srec));					\
 }while(0)
 
-#define makenewsusp(var,srec,allocp)					\
+#define makenewsusp(var,srec)					\
 do{									\
-  initnewsusp((allocp), (var), (srec));					\
-  (allocp) += sizeof(struct susprec)/sizeof(q)+1;			\
+  q* allocp = klic_alloc(sizeof(struct susprec) / sizeof(q) + 1);	\
+  initnewsusp(allocp, (var), (srec));					\
 }while(0)
 
 #define initnewsusp(temp,var,srec)					\
@@ -76,11 +76,10 @@
   initnewhook((oldhook), (newhook));					\
 }while(0)
 
-#define addhook(oldhook,newhook,allocp)					\
+#define addhook(oldhook,newhook)					\
 do{									\
-  (newhook) = (struct hook*) (allocp);					\
+  (newhook) = (struct hook*) klic_alloc(sizeof(struct hook) / sizeof(q)); \
   initnewhook((oldhook), (newhook));					\
-  (allocp) += sizeof(struct hook) / sizeof(q);				\
 }while(0)
 
 #define initnewhook(oldhook,newhook)					\
diff -ruN klic-3.003-2002-03-08a/include/klic/unify.h klic-3.003-2002-03-08b/include/klic/unify.h
--- klic-3.003-2002-03-08a/include/klic/unify.h	Fri Feb 22 09:25:09 2002
+++ klic-3.003-2002-03-08b/include/klic/unify.h	Fri Mar  8 20:10:33 2002
@@ -9,46 +9,67 @@
 #define _KLIC_UNIFY_H_
 
 /* runtime/unify.c */
-extern q* do_unify(q* allocp, q x, q y);
-extern q* do_unify2(q* allocp, q x, q y, q z, q w);
-extern q* do_unify3(q* allocp, q x, q y, q z, q w, q s, q t);
-extern q* do_unify4(q* allocp, q x, q y, q z, q w, q s, q t, q u, q v);
-extern q* do_unify_value(q* allocp, q x, q y);
-extern q* do_unify_value2(q* allocp, q x, q y, q z, q w);
-extern q* do_unify_value3(q* allocp, q x, q y, q z, q w, q s, q t);
-extern q* do_unify_value4(q* allocp, q x, q y, q z, q w, q s, q t, q u, q v);
+extern void do_unify(q x, q y);
+extern void do_unify2(q x, q y, q z, q w);
+extern void do_unify3(q x, q y, q z, q w, q s, q t);
+extern void do_unify4(q x, q y, q z, q w, q s, q t, q u, q v);
+extern void do_unify_value(q x, q y);
+extern void do_unify_value2(q x, q y, q z, q w);
+extern void do_unify_value3(q x, q y, q z, q w, q s, q t);
+extern void do_unify_value4(q x, q y, q z, q w, q s, q t, q u, q v);
 
 #define unify(x, y) \
-do{ allocp = do_unify(allocp, (x), (y)); }while(0)
+do{ \
+  set_heapp(allocp); \
+  do_unify((x), (y)); \
+  allocp = heapp(); \
+}while(0)
 
 #define unify2(x, y, z, w) \
-do{ allocp = do_unify2(allocp, (x), (y), (z), (w)); }while(0)
+do{ \
+  set_heapp(allocp); \
+  do_unify2((x), (y), (z), (w)); \
+  allocp = heapp(); \
+}while(0)
 
 #define unify3(x, y, z, w, s, t) \
-do{ allocp = do_unify3(allocp, (x), (y), (z), (w), (s), (t)); }while(0)
+do{ \
+  set_heapp(allocp); \
+  do_unify3((x), (y), (z), (w), (s), (t)); \
+  allocp = heapp(); \
+}while(0)
 
 #define unify4(x, y, z, w, s, t, u, v) \
-do{ allocp = do_unify4(allocp, (x), (y), (z), (w), (s), (t), (u), (v)); }while(0)
+do{ \
+  set_heapp(allocp); \
+  do_unify4((x), (y), (z), (w), (s), (t), (u), (v)); \
+  allocp = heapp(); \
+}while(0)
 
 #define unify_value(x, y)\
 do{								\
   if (!isref(x) || derefone(x) != (x)) {			\
-    allocp = do_unify_value(allocp, (x), (y));			\
+    set_heapp(allocp); \
+    do_unify_value((x), (y)); \
+    allocp = heapp(); \
   } else {							\
     derefone(x) = (y);						\
   }								\
 }while(0)
+
 #define unify_value2(x, y, z, w)\
 do{								\
   unify_value((x), (y));					\
   unify_value((z), (w));					\
 }while(0)
+
 #define unify_value3(x, y, z, w, s, t)\
 do{								\
   unify_value((x), (y));					\
   unify_value((z), (w));					\
   unify_value((s), (t));					\
 }while(0)
+
 #define unify_value4(x, y, z, w, s, t, u, v)\
 do{								\
   unify_value((x), (y));					\
diff -ruN klic-3.003-2002-03-08a/runtime/asyncio.c klic-3.003-2002-03-08b/runtime/asyncio.c
--- klic-3.003-2002-03-08a/runtime/asyncio.c	Tue Feb 26 11:32:36 2002
+++ klic-3.003-2002-03-08b/runtime/asyncio.c	Fri Mar  8 20:10:33 2002
@@ -195,12 +195,11 @@
   if (asyncio_streams[fd] == NULL) {
     klic_fprintf(stderr, "Unexpected IO interrupt for fd %d ignored\n", fd);
   } else {
-    q* allocp = heapp();
+    q* allocp = klic_alloc(2);
     q newcons = makecons(allocp);
     q newvar = allocp[0] = makeref(&allocp[0]);
     allocp[1] = makeint(fd);
-    allocp += 2;
-    set_heapp (do_unify_value (allocp, asyncio_streams[fd], newcons));
+    do_unify_value(asyncio_streams[fd], newcons);
     asyncio_streams[fd] = newvar;
   }
   return 0;
diff -ruN klic-3.003-2002-03-08a/runtime/cntlmsg.c klic-3.003-2002-03-08b/runtime/cntlmsg.c
--- klic-3.003-2002-03-08a/runtime/cntlmsg.c	Mon Mar  4 10:37:35 2002
+++ klic-3.003-2002-03-08b/runtime/cntlmsg.c	Fri Mar  8 20:10:33 2002
@@ -111,8 +111,10 @@
 
     /* Hack to avoid sending %unify when a ReadHook receives answer_value. */
     answer_return_exp_index = return_index;
-    
-    allocp = do_unify(allocp, exref, decode_data);
+
+    set_heapp(allocp);
+    do_unify(exref, decode_data);
+    allocp = heapp();
     
     answer_return_exp_index = -1;
     receive_answer_flag = 0;
@@ -193,8 +195,10 @@
 	/* Hack to avoid sending %unify when
 	   a ReadHook receives answer_value. */
 	answer_return_exp_index = index;
-    
-	allocp = do_unify(allocp, readhook, data);
+
+	set_heapp(allocp);
+	do_unify(readhook, data);
+	allocp = heapp();
     
 	answer_return_exp_index = -1;
 	receive_answer_flag = 0;
@@ -231,9 +235,8 @@
   
     new_generic(reply_hook_g_new, 3, rhook, 0);
     assert(allocp == heapp());
-    
-    allocp = do_unify(allocp ,rhook, data);
-    return(allocp);
+    do_unify(rhook, data);
+    return heapp();
     
  atomic_label:
  cons_label:
@@ -393,9 +396,10 @@
 /*    decoder = (module)GET_BUFFER(inbuf);
     allocp = (q *)decoder(inbuf, allocp);*/
     decode_data = pop_decode_stack();
-    
-    allocp = do_unify(allocp, exp_data, decode_data);
-    return(allocp);
+
+    set_heapp(allocp);
+    do_unify(exp_data, decode_data);
+    return heapp();
 }
 
 static long
diff -ruN klic-3.003-2002-03-08a/runtime/faisus.c klic-3.003-2002-03-08b/runtime/faisus.c
--- klic-3.003-2002-03-08a/runtime/faisus.c	Fri Mar  8 16:48:58 2002
+++ klic-3.003-2002-03-08b/runtime/faisus.c	Fri Mar  8 20:10:33 2002
@@ -220,7 +220,7 @@
 	  /* no goals suspended yet on this variable */
 	  struct susprec* susp;
 	  q newvar;
-	  makenewsusp(newvar, susp, heapp());
+	  makenewsusp(newvar, susp);
 	  susp->u.first_hook.u.g = goal;
 	  derefone(tmp) = newvar;
 	} else {
@@ -234,7 +234,7 @@
 		 because of the loop structure of the hook chain. */
 	    } else {
 	      struct hook* newhook;
-	      addhook(&susp->u.first_hook, newhook, heapp());
+	      addhook(&susp->u.first_hook, newhook);
 	      newhook->u.g = goal;
 	    }
 	  } else {
diff -ruN klic-3.003-2002-03-08a/runtime/gg_shbusy.c klic-3.003-2002-03-08b/runtime/gg_shbusy.c
--- klic-3.003-2002-03-08a/runtime/gg_shbusy.c	Fri Jan 18 15:37:50 2002
+++ klic-3.003-2002-03-08b/runtime/gg_shbusy.c	Fri Mar  8 20:10:33 2002
@@ -15,31 +15,30 @@
 #include <klic/g_basic.h>
 #include <klic/gg_macro.h>
 #include <klic/susp.h>
+#include <klic/unify.h>  /* do_unify */
 #include "shm.h"
 
 #define GG_CLASS_NAME() shbusy
 #define GG_OBJ_TYPE struct Shbusy
 
-#define One_more  do_unify(g_allocp, GG_SELF, GG_TERM)
+#define One_more()  (set_heapp(g_allocp), do_unify(GG_SELF, GG_TERM), heapp())
 
 struct Shbusy {
   struct generator_object_method_table *method_table;
 };
 
-extern q* do_unify();
-
 GGDEF_UNIFY()
 {
   G_STD_DECL;
 
   struct generator_object* gobj;
   q pair = derefone(GG_SELF);
-  if( !isref(pair) || GG_SELF != derefone(pair) ){ return One_more; }
+  if( !isref(pair) || GG_SELF != derefone(pair) ){ return One_more(); }
   gobj = n_lock(GG_SELF, pair);
   if( derefone(GG_SELF) == pair ){
     n_unlock(pair, gobj);
   }
-  return One_more;
+  return One_more();
 }
 
 GGDEF_GENERATE()
diff -ruN klic-3.003-2002-03-08a/runtime/gg_shvar.c klic-3.003-2002-03-08b/runtime/gg_shvar.c
--- klic-3.003-2002-03-08a/runtime/gg_shvar.c	Mon Feb 25 13:15:12 2002
+++ klic-3.003-2002-03-08b/runtime/gg_shvar.c	Fri Mar  8 20:10:33 2002
@@ -12,6 +12,7 @@
 #include <klic/g_basic.h>
 #include <klic/gg_macro.h>
 #include <klic/susp.h>
+#include <klic/unify.h>  /* do_unify */
 #include "gobj.h"
 #include "shm.h"
 
@@ -21,7 +22,7 @@
 #define GG_CLASS_NAME() shvar
 #define GG_OBJ_TYPE struct Shvar
 
-#define One_more  do_unify(g_allocp, GG_SELF, GG_TERM)
+#define One_more()  (set_heapp(g_allocp), do_unify(GG_SELF, GG_TERM), heapp())
 
 struct Shvar {
   struct generator_object_method_table *method_table;
@@ -31,8 +32,6 @@
 extern Sinfo* shm_copy_chain();
 extern Sinfo* shm_merge_chain();
 
-extern q* do_unify();
-
 static Inline int
 cmp_forward_ptr(q x, q y)
 {
@@ -63,9 +62,9 @@
   struct generator_object *addi;
   Shvar *gobjp;
   q pair = derefone(GG_SELF);
-  if( !isref(pair) || GG_SELF != derefone(pair) )  return One_more;
+  if( !isref(pair) || GG_SELF != derefone(pair) )  return One_more();
   addi = n_lock(GG_SELF, pair);
-  if( pair != derefone(GG_SELF) )  return One_more;
+  if( pair != derefone(GG_SELF) )  return One_more();
 
   gobjp = (Shvar*) untag_generator_susp(addi);
   GG_SWITCH_ON_TERM(cons, atomic, func, dobj, susp);
@@ -124,11 +123,11 @@
     ytemp = derefone(y);
     if( !isref(ytemp) ){
       n_unlock(temp, xaddi);
-      return One_more;
+      return One_more();
     }
     if( y != derefone(ytemp) ){
       n_unlock(temp, xaddi);
-      return One_more;
+      return One_more();
     }
     yaddi = generator_suspp(ytemp)->u.o;
     /* if yaddi is generator_susp */
@@ -148,7 +147,7 @@
 	  w = temp; temp = ytemp; ytemp = w;
 	  xaddi = n_lock(x, temp);
 	  if( temp != derefone(x) ){
-	    return One_more;
+	    return One_more();
 	  }
 	  xobjp = (Shvar*) untag_generator_susp(xaddi);
 	}
@@ -161,7 +160,7 @@
 	    yaddi = n_lock(y, ytemp);
 	    if( derefone(y) != ytemp ){
 	      n_unlock(temp,xaddi);
-	      return One_more;
+	      return One_more();
 	    }
 	    yobjp = (Shvar*) untag_generator_susp(yaddi);
 	    if( yobjp->chain ){
@@ -210,7 +209,7 @@
 	  default:
 	    g_allocp = heapp();
 	    derefone(y) = tmpy;
-	    return One_more;
+	    return One_more();
 	  }
 	}else{ /* x is a simple variable */
 	  xobjp = create_genhook(tag_local(y), x);
diff -ruN klic-3.003-2002-03-08a/runtime/ktimer.c klic-3.003-2002-03-08b/runtime/ktimer.c
--- klic-3.003-2002-03-08a/runtime/ktimer.c	Tue Feb 19 15:22:50 2002
+++ klic-3.003-2002-03-08b/runtime/ktimer.c	Fri Mar  8 20:11:06 2002
@@ -6,12 +6,15 @@
 ----------------------------------------------------------- */
 
 #include <klic/basic.h>
+
 #ifdef USETIMER
+
 #include <sys/time.h>
 #include <klic/alloc.h>  /* malloc_check, register_gc_hook */
 #include <klic/struct.h>
 #include "timer.h"
 #include <klic/sighndl.h>
+#include <klic/unify.h>  /* do_unify_value */
 
 extern void copy_one_term();
 
@@ -39,9 +42,9 @@
      q data;
 {
   declare_globals;
-  extern q *do_unify_value();
 
-  set_heapp(do_unify_value(allocp, data, NILATOM));
+  set_heapp(allocp);
+  do_unify_value(data, NILATOM);
   return 0;
 }
 
@@ -177,4 +180,5 @@
   process_timer_interrupt(allocp, SIGALRM);
   return heapp();
 }
-#endif
+
+#endif  /* USETIMER */
diff -ruN klic-3.003-2002-03-08a/runtime/shm_obj.c klic-3.003-2002-03-08b/runtime/shm_obj.c
--- klic-3.003-2002-03-08a/runtime/shm_obj.c	Mon Feb 25 15:57:10 2002
+++ klic-3.003-2002-03-08b/runtime/shm_obj.c	Fri Mar  8 20:10:33 2002
@@ -11,7 +11,7 @@
 #include <klic/primitives.h>  /* enqueue_goal */
 #include <klic/functorstuffs.h>
 #include <klic/index.h>
-#include <klic/unify.h>
+#include <klic/unify.h>  /* do_unify */
 #include <klic/susp.h>
 #include <klic/gg_macro.h>
 #include "shm.h"
@@ -285,7 +285,9 @@
 	q top = (q) &sptr->localA;
 	derefone(top) = wp;
 	derefone(wp) = top;
-	allocp = do_unify(allocp, top, shm_term);
+	set_heapp(allocp);
+	do_unify(top, shm_term);
+	allocp = heapp();
       }else{
 	struct goalrec* goal = (struct goalrec*) term;
 	if( goal != NULL && isatomic(goal->next) ){
@@ -340,7 +342,9 @@
     q temp;
     free_local_tbl(indp);
     shm_arg_copy(&indp->localA, &temp);
-    allocp = do_unify(allocp, indp->globalA, temp);
+    set_heapp(allocp);
+    do_unify(indp->globalA, temp);
+    allocp = heapp();
   }else{
     shm_request_queueing(penum, current_prio(), indp);
   }
@@ -381,7 +385,9 @@
     derefone(top) = x;
     derefone(x) = top;
     qp = qp->next;
-    allocp = do_unify(allocp, top, tp->globalA);
+    set_heapp(allocp);
+    do_unify(top, tp->globalA);
+    allocp = heapp();
   }else{
     struct goalrec* gp = (struct goalrec*) (tp->localA);
     if( gp != NULL && isatomic(gp->next) ){
@@ -412,11 +418,12 @@
 
   if( isatomic(tp->localA) ){  /* local generator object */
     q x = untag_local(tp->localA);
-    allocp = do_unify(allocp, x, var);
+    set_heapp(allocp);
+    do_unify(x, var);
   }else{  /* shared-memory generator hook */
-    allocp = do_unify(allocp, tp->localA, var);
+    set_heapp(allocp);
+    do_unify(tp->localA, var);
   }
-  set_heapp(allocp);
   current_queue = qp;
   return (module) (qp->pred)->func;
 }
diff -ruN klic-3.003-2002-03-08a/runtime/signal.c klic-3.003-2002-03-08b/runtime/signal.c
--- klic-3.003-2002-03-08a/runtime/signal.c	Mon Feb 25 14:04:55 2002
+++ klic-3.003-2002-03-08b/runtime/signal.c	Fri Mar  8 20:11:18 2002
@@ -8,9 +8,11 @@
 #include <klic/basic.h>  /* fatalf */
 
 #ifdef USESIG
+
 #include <klic/alloc.h>  /* register_gc_hook */
 #include <klic/struct.h>
 #include <klic/sighndl.h>
+#include <klic/unify.h>  /* do_unify, do_unify_value */
 
 #define signal_handlers		(klic_sgnl_flags->sgnl_handlers)
 
@@ -161,14 +163,13 @@
      int sig;
 {
   declare_globals;
-  extern q *do_unify_value();
   q newcons = makecons(allocp);
   q newvar = allocp[0] = makeref(&allocp[0]);
   allocp[1] = makeint(sig);
   allocp += 2;
-  allocp = do_unify_value(allocp, signal_streams[sig], newcons);
-  signal_streams[sig] = newvar;
   set_heapp(allocp);
+  do_unify_value(signal_streams[sig], newcons);
+  signal_streams[sig] = newvar;
   return 0;
 }
 
@@ -177,15 +178,12 @@
      int sig;
      q stream;
 {
-  extern q *do_unify();
-  q* allocp = heapp();
   if (signal_streams[sig] == 0) {
     signal_streams[sig] = stream;
     add_signal_handler(sig, streamed_signal_handler);
   } else {
-    allocp = do_unify(allocp, stream, signal_streams[sig]);
+    do_unify(stream, signal_streams[sig]);
   }
-  set_heapp(allocp);
 }
 
 /* Initiation */
diff -ruN klic-3.003-2002-03-08a/runtime/step.c klic-3.003-2002-03-08b/runtime/step.c
--- klic-3.003-2002-03-08a/runtime/step.c	Mon Feb 25 13:17:20 2002
+++ klic-3.003-2002-03-08b/runtime/step.c	Fri Mar  8 20:10:33 2002
@@ -12,12 +12,11 @@
 #include <klic/primitives.h>  /* malloc_check, realloc_check */
 #include "goalobj.h"
 #include <klic/generic.h>
+#include <klic/unify.h>  /* do_unify_value */
 #include "atom.h"
 #include "funct.h"
 #include "step.h"  /* stepping_flag */
 
-extern q* do_unify_value();
-
 /* Global flag for stepping */
 int stepping_flag = 0;
 
@@ -105,12 +104,10 @@
      q children, wokenup, failure, susp;
 {
   struct goalrec *trigger = step_trigger_goal;
-  q* allocp = heapp();
-  allocp = do_unify_value(allocp, trigger->args[1], children);
-  allocp = do_unify_value(allocp, trigger->args[2], wokenup);
-  allocp = do_unify_value(allocp, trigger->args[3], failure);
-  allocp = do_unify_value(allocp, trigger->args[4], susp);
-  set_heapp(allocp);
+  do_unify_value(trigger->args[1], children);
+  do_unify_value(trigger->args[2], wokenup);
+  do_unify_value(trigger->args[3], failure);
+  do_unify_value(trigger->args[4], susp);
 }
 
 extern struct goalrec*
diff -ruN klic-3.003-2002-03-08a/runtime/unify.c klic-3.003-2002-03-08b/runtime/unify.c
--- klic-3.003-2002-03-08a/runtime/unify.c	Mon Mar  4 10:44:42 2002
+++ klic-3.003-2002-03-08b/runtime/unify.c	Fri Mar  8 20:10:33 2002
@@ -15,6 +15,7 @@
 #include <klic/susp.h>
 #include <klic/unify.h>  /* do_unify* */
 #include "trace.h"  /* trace_flag, trace_resumption */
+#include "step.h"  /* stepping_flag, step_wokenup */
 
 extern struct predicate predicate_unify__term__dcode_xunify_2;
 extern struct predicate predicate_unify__term__dcode_xunify__goal_2;
@@ -32,26 +33,24 @@
 extern void set_rest_of_stream(q term){ rest_of_stream = term; }
 extern void set_method_result(q term){ method_result = term; }
 
-#define enqueue_unify_terms(x, y) \
-{ \
-  struct goalrec *gp = (struct goalrec *)allocp; \
-  gp->next = (struct goalrec*) makeint(current_prio()); \
-  gp->pred = &predicate_unify__term__dcode_xunify_2; \
-  gp->args[0] = x; \
-  gp->args[1] = y; \
-  allocp += 4; \
-  resume_same_prio(gp); \
-}
-
-#define enqueue_unify_goal(x, y) \
-{ \
-  struct goalrec *gp = (struct goalrec *)allocp; \
-  gp->next = (struct goalrec*) makeint(current_prio()); \
-  gp->pred = &predicate_unify__term__dcode_xunify__goal_2; \
-  gp->args[0] = (x); \
-  gp->args[1] = (y); \
-  allocp += 4; \
-  resume_same_prio(gp); \
+static void enqueue_unify_terms(q x, q y)
+{
+  struct goalrec* gp = (struct goalrec*) klic_alloc(4);
+  gp->next = (struct goalrec*) makeint(current_prio());
+  gp->pred = &predicate_unify__term__dcode_xunify_2;
+  gp->args[0] = x;
+  gp->args[1] = y;
+  resume_same_prio(gp);
+}
+
+static void enqueue_unify_goal(q x, q y)
+{
+  struct goalrec* gp = (struct goalrec*) klic_alloc(4);
+  gp->next = (struct goalrec*) makeint(current_prio());
+  gp->pred = &predicate_unify__term__dcode_xunify__goal_2;
+  gp->args[0] = (x);
+  gp->args[1] = (y);
+  resume_same_prio(gp);
 }
 
 /* Resume a goal with the same priority as current */
@@ -70,13 +69,13 @@
   by the unification with `y'
 */
 
-extern Inline q*
-resume_goals(allocp, x, y)
-     q * allocp;
+static void
+resume_goals(x, y)
      q x;
      q y;
 {
   declare_globals;
+  q* allocp = heapp();
 
   /* Variable x with suspended goals is instantiated here */
   /* x points suspension record directly. */
@@ -105,7 +104,9 @@
       case (long)makeref(0):
 	/* x is a reference to suspension record. thus
 	   derefone is needed for enqueue */
+	set_heapp(allocp);
 	enqueue_unify_goal(derefone(x), y);
+	allocp = heapp();
 	break;
       case (long)makecons(0):
 	fatal("invalid situation in generator unification");
@@ -115,7 +116,9 @@
 	if(isref(tmp) && tmp == derefone(tmp)) {
 	  derefone(tmp) = y;
 	} else {
-	  allocp = do_unify(allocp, tmp, y);
+	  set_heapp(allocp);
+	  do_unify(tmp, y);
+	  allocp = heapp();
 	}
       }
     }
@@ -153,30 +156,33 @@
 	      loopp->u.l = keepp;
 	      susprecord->backpt = newvar;
 	      derefone(newvar) = (q)susprecord;
+	      set_heapp(allocp);
 	      enqueue_unify_goal(y, newvar);
 	    }
 	    /* exit the loop */
-	    return(allocp);
+	    return;
 	  default:
 	    tmpval = method_result;
 	  }
 	  {
 	    struct susprec *susp;
 	    q newvar;
-	    makenewsusp(newvar,susp,allocp);
+	    set_heapp(allocp);
+	    makenewsusp(newvar, susp);
+	    allocp = heapp();
 	    susp->u.first_hook.u.o = tag_consumer_hook(obj);
 	    if (derefone(tmpval) == tmpval) {
 	      derefone(tmpval) = newvar;
 	    } else {
+	      set_heapp(allocp);
 	      enqueue_unify_goal(tmpval, newvar);
+	      allocp = heapp();
 	    }
 	  }
 	consumer_terminate:;
 	} else if (isint(u.g->next)) {
 	  long gp = intval(u.g->next);
-	  extern int stepping_flag;
 	  if (stepping_flag) {
-	    extern void step_wokenup();
 	    u.g->next = 0;	/* to nullify deadlock check */
 	    step_wokenup(u.g, gp);
 	  } else
@@ -194,7 +200,7 @@
       loopp = loopp->next;
     } while (loopp != top);
   }
-  return allocp;
+  set_heapp(allocp);
 }
 
 static Inline void
@@ -243,7 +249,9 @@
 	  q tmpy = generic_generate(gobjy, allocp);
 	  switch((long)tmpy) {
 	  case (long)makeref(0):
+	    set_heapp(allocp);
 	    enqueue_unify_goal(gsx->backpt, sy->backpt);
+	    allocp = heapp();
 	    break;
 	  case (long)makecons(0):
 	    fatal("invalid situation at the generator unification");
@@ -253,7 +261,9 @@
 	    if(isref(tmpy) && tmpy == derefone(tmpy)) {
 	      derefone(tmpy) = gsx->backpt;
 	    } else {
-	      allocp = do_unify(allocp, tmpy, gsx->backpt);
+	      set_heapp(allocp);
+	      do_unify(tmpy, gsx->backpt);
+	      allocp = heapp();
 	    }
 	  }
 	  break;
@@ -266,7 +276,8 @@
 	  if(isref(tmpx) && tmpx == derefone(tmpx)) {
 	    derefone(sy->backpt) = tmpx;
 	  } else {
-	    set_heapp (do_unify (allocp, tmpx, sy->backpt));
+	    set_heapp(allocp);
+	    do_unify(tmpx, sy->backpt);
 	    return;
 	  }
 	}
@@ -278,7 +289,9 @@
       q tmpx = generic_generate(gobjx, allocp);
       switch((long)tmpx) {
       case (long)makeref(0): /* GC request */
+	set_heapp(allocp);
 	enqueue_unify_goal(gsx->backpt, sy->backpt);
+	allocp = heapp();
 	break;
       case (long)makecons(0): /* invalid */
 	fatal("invalid situation at the generator unification");
@@ -288,7 +301,8 @@
 	if(isref(tmpx) && tmpx == derefone(tmpx)) {
 	  derefone(tmpx) = sy->backpt;
 	} else {
-	  set_heapp (do_unify (allocp, tmpx, sy->backpt));
+	  set_heapp(allocp);
+	  do_unify(tmpx, sy->backpt);
 	  return;
 	}
       }
@@ -297,9 +311,8 @@
   set_heapp(allocp);
 }
 
-extern q*
-do_unify(allocp, x, y)
-     q * allocp;
+extern void
+do_unify(x, y)
      q x, y;
 {
 #ifdef UNIFYDEBUG
@@ -322,7 +335,7 @@
 	      /* Suspension records must be referenced through REF. */
 	      /* Thus, doing "derefone(y) = temp;" here is buggy. */
 	      derefone(y) = x;
-	      return allocp;
+	      return;
 	    } else {
 	      if (isref(ytemp) && derefone(ytemp) == y) {
 		y = ytemp;
@@ -332,13 +345,11 @@
 		  struct susprec *sx = (struct susprec *)x;
 		  struct susprec *sy = (struct susprec *)y;
 		  if(is_generator_susp(sx->u)) {
-		    set_heapp(allocp);
 		    generator_unify(generator_suspp(sx), sy);
-		    return heapp();
+		    return;
 		  } else if(is_generator_susp(sy->u)) {
-		    set_heapp(allocp);
 		    generator_unify(generator_suspp(sy), sx);
-		    return heapp();
+		    return;
 		  } else {
 		    /* Both x and y are not generator */
 		    /* None of two is generator, then merge ... */
@@ -349,13 +360,14 @@
 		    derefone(sy->backpt) = sx->backpt;
 		  }
 		}
-		return allocp;
+		return;
 	      }
 	    }
 	    y = ytemp;
 	  }
 	  /* x is hook variable and y points a real object */
-	  return resume_goals(allocp, temp, y);
+	  resume_goals(temp, y);
+	  return;
 	} else {
 	  x = temp;
 	  temp = temp1;
@@ -372,7 +384,7 @@
 	y = temp;
       }
       derefone(x) = y;		/* this also handles x==y cases */
-      return allocp;
+      return;
     }
   }
 
@@ -381,10 +393,11 @@
     q temp = derefone(y);
     if (temp == y) { /* y is undef cell */
       derefone(y) = x;
-      return allocp;
+      return;
     } else {
       if(isref(temp) && derefone(temp) == y) {
-	return resume_goals(allocp, temp, x);
+	resume_goals(temp, x);
+	return;
       }
     }
     y = temp;
@@ -395,7 +408,6 @@
     declare_globals;
     enqueue_unify_terms(x, y);
   } 
-  return allocp;
 }
 
 extern void
@@ -427,16 +439,16 @@
 	      return;
 	    } else {
 	      if (isref(ytemp) && derefone(ytemp) == y) {
-		enqueue_unify_goal(x, y);
 		set_heapp(allocp);
+		enqueue_unify_goal(x, y);
 		return;
 	      }
 	    }
 	    y = ytemp;
 	  }
 	  /* x is hook variable and y points a real object */
-	  enqueue_unify_goal(x, y);
 	  set_heapp(allocp);
+	  enqueue_unify_goal(x, y);
 	  return;
 	} else {
 	  x = temp;
@@ -468,8 +480,8 @@
       return;
     } else {
       if(isref(temp) && derefone(temp) == y) {
-	enqueue_unify_goal(x, y);
 	set_heapp(allocp);
+	enqueue_unify_goal(x, y);
 	return;
       }
     }
@@ -478,55 +490,56 @@
 
   /* Both x and y are bound */
   if (x != y) {
+    set_heapp(allocp);
     enqueue_unify_goal(x, y);
+    allocp = heapp();
   } 
   set_heapp(allocp);
 }
 
-extern q*
-do_unify2(allocp, x, y, z, w)
-     q *allocp;
+extern void
+do_unify2(x, y, z, w)
      q x, y, z, w;
 {
-  allocp = do_unify(allocp, x, y);
-  return do_unify(allocp, z, w);
+  do_unify(x, y);
+  do_unify(z, w);
 }
 
-extern q*
-do_unify3(allocp, x, y, z, w, s, t)
-     q *allocp;
+extern void
+do_unify3(x, y, z, w, s, t)
      q x, y, z, w, s, t;
 {
-  allocp = do_unify(allocp, x, y);
-  allocp = do_unify(allocp, z, w);
-  return do_unify(allocp, s, t);
+  do_unify(x, y);
+  do_unify(z, w);
+  do_unify(s, t);
 }
 
-extern q*
-do_unify4(allocp, x, y, z, w, s, t, u, v)
-     q *allocp;
+extern void
+do_unify4(x, y, z, w, s, t, u, v)
      q x, y, z, w, s, t, u, v;
 {
-  allocp = do_unify(allocp, x, y);
-  allocp = do_unify(allocp, z, w);
-  allocp = do_unify(allocp, s, t);
-  return do_unify(allocp, u, v);
+  do_unify(x, y);
+  do_unify(z, w);
+  do_unify(s, t);
+  do_unify(u, v);
 }
 
 /*
   do_unify_value(allocp, x, y)
 	"do_unify" for when "y" is known to be instantiated.
 */
-extern q*
-do_unify_value(allocp, x, y)
-     q * allocp;
+extern void
+do_unify_value(x, y)
      q x, y;
 {
+  q* allocp = heapp();
+
   if (isref(x)) {
     q temp = derefone(x);
     if (x == temp) {
       derefone(x) = y;
-      return allocp;
+      set_heapp(allocp);
+      return;
     } else if (isref(temp)) {
       q temp1;
     again:
@@ -534,22 +547,27 @@
       if (isref(temp1)) {
 	if (temp1 == temp) {
 	  derefone(temp) = y;
-	  return allocp;
+	  set_heapp(allocp);
+	  return;
 	} else if (temp1 == x) {
-	  return resume_goals(allocp, temp, y);
+	  set_heapp(allocp);
+	  resume_goals(temp, y);
+	  return;
 	} else {
 	  x = temp;
 	  temp = temp1;
 	  goto again;
 	}
       } else {
-	return do_unify(allocp, temp1, y);
+	do_unify(temp1, y);
+	return;
       }
     } else {
-      return do_unify(allocp, temp, y);
+      do_unify(temp, y);
+      return;
     }
   }
-  return do_unify(allocp, x, y);
+  do_unify(x, y);
 }
 
 extern void
@@ -573,7 +591,8 @@
 	  set_heapp(allocp);
 	  return;
 	} else if (temp1 == x) {
-	  set_heapp(resume_goals(allocp, temp, y));
+	  set_heapp(allocp);
+	  resume_goals(temp, y);
 	  return;
 	} else {
 	  x = temp;
@@ -595,32 +614,29 @@
   do_shallow_unify(x, y);
 }
 
-extern q*
-do_unify_value2(allocp, x, y, z, w)
-     q *allocp;
+extern void
+do_unify_value2(x, y, z, w)
      q x, y, z, w;
 {
-  allocp = do_unify_value(allocp, x, y);
-  return do_unify_value(allocp, z, w);
+  do_unify_value(x, y);
+  do_unify_value(z, w);
 }
 
-extern q*
-do_unify_value3(allocp, x, y, z, w, s, t)
-     q *allocp;
+extern void
+do_unify_value3(x, y, z, w, s, t)
      q x, y, z, w, s, t;
 {
-  allocp = do_unify_value(allocp, x, y);
-  allocp = do_unify_value(allocp, z, w);
-  return do_unify_value(allocp, s, t);
+  do_unify_value(x, y);
+  do_unify_value(z, w);
+  do_unify_value(s, t);
 }
 
-extern q*
-do_unify_value4(allocp, x, y, z, w, s, t, u, v)
-     q *allocp;
+extern void
+do_unify_value4(x, y, z, w, s, t, u, v)
      q x, y, z, w, s, t, u, v;
 {
-  allocp = do_unify_value(allocp, x, y);
-  allocp = do_unify_value(allocp, z, w);
-  allocp = do_unify_value(allocp, s, t);
-  return do_unify_value(allocp, u, v);
+  do_unify_value(x, y);
+  do_unify_value(z, w);
+  do_unify_value(s, t);
+  do_unify_value(u, v);
 }
