diff -ruN klic-3.003-2002-02-17c/include/klic/g_extern.h klic-3.003-2002-02-17d/include/klic/g_extern.h
--- klic-3.003-2002-02-17c/include/klic/g_extern.h	Thu Dec 27 19:15:58 2001
+++ klic-3.003-2002-02-17d/include/klic/g_extern.h	Sun Feb 17 15:40:19 2002
@@ -9,7 +9,7 @@
 #define _KLIC_G_EXTERN_H_
 
 /* runtime/gc.c */
-extern q general_gc(q* term, q* allocp, q** sp);
+extern q general_gc(q* term, q** sp);
 
 /* runtime/print.c */
 extern void general_print(
diff -ruN klic-3.003-2002-02-17c/include/klic/gc_macro.h klic-3.003-2002-02-17d/include/klic/gc_macro.h
--- klic-3.003-2002-02-17c/include/klic/gc_macro.h	Sun Feb 17 15:16:02 2002
+++ klic-3.003-2002-02-17d/include/klic/gc_macro.h	Sun Feb 17 15:59:14 2002
@@ -14,8 +14,8 @@
 extern q GC_wakeup_g_new();
 
 /* runtime/unify.c */
-extern q* do_shallow_unify(q* allocp, q x, q y);
-extern q* do_shallow_unify_value(q* allocp, q x, q y);
+extern void do_shallow_unify(q x, q y);
+extern void do_shallow_unify_value(q x, q y);
 
 /* runtime/generic.c */
 extern q* G_SUSPEND(q x, struct goalrec* goal, q* g_allocp);
@@ -242,11 +242,15 @@
 }while(0)
 
 
-#define GC_UNIFY(x,y)  (g_allocp = do_shallow_unify(g_allocp, (x), (y)))
+#define GC_UNIFY(x,y) \
+  (set_heapp(g_allocp), do_shallow_unify((x), (y)), g_allocp = heapp())
+
 #define GC_UNIFY_VALUE(x, y)					\
 do{								\
   if (!isref(x) || derefone(x) != (x)) {			\
-    g_allocp = do_shallow_unify_value(g_allocp, (x), (y));	\
+    set_heapp(g_allocp); \
+    do_shallow_unify_value((x), (y));	\
+    g_allocp = heapp(); \
   } else {							\
     derefone(x) = (y);						\
   }								\
diff -ruN klic-3.003-2002-02-17c/include/klic/gd_macro.h klic-3.003-2002-02-17d/include/klic/gd_macro.h
--- klic-3.003-2002-02-17c/include/klic/gd_macro.h	Sun Feb 17 15:17:36 2002
+++ klic-3.003-2002-02-17d/include/klic/gd_macro.h	Sun Feb 17 16:00:08 2002
@@ -16,8 +16,8 @@
 extern q eq_terms_body(q x, q y);
 
 /* runtime/unify.c */
-extern q* do_shallow_unify(q* allocp, q x, q y);
-extern q* do_shallow_unify_value(q* allocp, q x, q y);
+extern void do_shallow_unify(q x, q y);
+extern void do_shallow_unify_value(q x, q y);
 
 
 /* runtime/generic.c */
@@ -274,12 +274,18 @@
 #define GD_GUNIFY(x,y) eq_terms_body(x,y)
 
 #define GD_UNIFY(x,y) \
-do{ g_allocp = do_shallow_unify(g_allocp, (x), (y)); }while(0)
+do{ \
+  set_heapp(g_allocp); \
+  do_shallow_unify((x), (y)); \
+  g_allocp = heapp(); \
+}while(0)
 
 #define GD_UNIFY_VALUE(x,y) \
 do{								\
   if (!isref(x) || derefone(x) != (x)) {			\
-    g_allocp = do_shallow_unify_value(g_allocp, (x), (y));	\
+    set_heapp(g_allocp); \
+    do_shallow_unify_value((x), (y));	\
+    g_allocp = heapp(); \
   } else {							\
     derefone(x) = (y);						\
   }								\
diff -ruN klic-3.003-2002-02-17c/include/klic/gg_macro.h klic-3.003-2002-02-17d/include/klic/gg_macro.h
--- klic-3.003-2002-02-17c/include/klic/gg_macro.h	Sun Feb 17 15:18:25 2002
+++ klic-3.003-2002-02-17d/include/klic/gg_macro.h	Sun Feb 17 16:01:00 2002
@@ -14,8 +14,8 @@
 extern q GC_wakeup_g_new();
 
 /* runtime/unify.c */
-extern q* do_shallow_unify(q* allocp, q x, q y);
-extern q* do_shallow_unify_value(q* allocp, q x, q y);
+extern void do_shallow_unify(q x, q y);
+extern void do_shallow_unify_value(q x, q y);
 
 
 /* runtime/generic.c */
@@ -129,7 +129,8 @@
   } \
 }while(0)
 
-#define GG_UNIFY(x,y)  (g_allocp = do_shallow_unify(g_allocp, (x), (y)))
+#define GG_UNIFY(x,y) \
+  (set_heapp(g_allocp), do_shallow_unify((x), (y)), g_allocp = heapp())
 
 /**************************************************************************/
 
diff -ruN klic-3.003-2002-02-17c/runtime/export_table.c klic-3.003-2002-02-17d/runtime/export_table.c
--- klic-3.003-2002-02-17c/runtime/export_table.c	Sat Feb 16 11:53:06 2002
+++ klic-3.003-2002-02-17d/runtime/export_table.c	Sun Feb 17 15:43:03 2002
@@ -167,7 +167,8 @@
   j = 0;
   for(i=0; i<current_exp_size; i++){
     if(exp_table[i].data != (q) UNUSED_EXPREC){
-      newdata = general_gc(&(exp_table[i].data), allocp, gcsp);
+      set_heapp(allocp);
+      newdata = general_gc(&(exp_table[i].data), gcsp);
       exp_table[i].data = newdata;
       allocp = heapp();
       j++;
diff -ruN klic-3.003-2002-02-17c/runtime/gc.c klic-3.003-2002-02-17d/runtime/gc.c
--- klic-3.003-2002-02-17c/runtime/gc.c	Sat Feb 16 11:55:38 2002
+++ klic-3.003-2002-02-17d/runtime/gc.c	Sun Feb 17 15:42:28 2002
@@ -773,12 +773,12 @@
   for generic object
 */
 extern q
-general_gc(term, allocp, sp)
+general_gc(term, sp)
   q* term;
-  q* allocp;
   q** sp;
 {
   declare_globals;
+  q* allocp = heapp();
 
   push_gc_stack(term, sp, gcmax);
   set_heapp( copy_terms(allocp, new_space_top, old_space_top,
diff -ruN klic-3.003-2002-02-17c/runtime/sendrecv.c klic-3.003-2002-02-17d/runtime/sendrecv.c
--- klic-3.003-2002-02-17c/runtime/sendrecv.c	Sat Feb 16 12:04:30 2002
+++ klic-3.003-2002-02-17d/runtime/sendrecv.c	Sun Feb 17 15:43:34 2002
@@ -539,7 +539,8 @@
 
   decode_stack_tmp = decode_stack;
   while( decode_stack_tmp != decode_stack_ptr ){
-    newdata = general_gc(decode_stack_tmp, allocp, gcsp);
+    set_heapp(allocp);
+    newdata = general_gc(decode_stack_tmp, gcsp);
     *decode_stack_tmp = newdata;
     allocp = heapp();
     decode_stack_tmp++;
diff -ruN klic-3.003-2002-02-17c/runtime/unify.c klic-3.003-2002-02-17d/runtime/unify.c
--- klic-3.003-2002-02-17c/runtime/unify.c	Sat Feb 16 12:06:09 2002
+++ klic-3.003-2002-02-17d/runtime/unify.c	Sun Feb 17 16:03:45 2002
@@ -392,9 +392,8 @@
   return allocp;
 }
 
-extern q*
-do_shallow_unify(allocp, x, y)
-     q * allocp;
+extern void
+do_shallow_unify(x, y)
      q x, y;
 {
   /*
@@ -404,6 +403,7 @@
     unifier to be called recursively from generic objects.
   */
   declare_globals;
+  q* allocp = heapp();
   if (isref(x)) {
     q temp = derefone(x);
   deref_x:
@@ -417,18 +417,21 @@
 	      /* Suspension records must be referenced through REF. */
 	      /* Thus, doing "derefone(y) = temp;" here is buggy. */
 	      derefone(y) = x;
-	      return allocp;
+	      set_heapp(allocp);
+	      return;
 	    } else {
 	      if (isref(ytemp) && derefone(ytemp) == y) {
 		enqueue_unify_goal(x, y);
-		return allocp;
+		set_heapp(allocp);
+		return;
 	      }
 	    }
 	    y = ytemp;
 	  }
 	  /* x is hook variable and y points a real object */
 	  enqueue_unify_goal(x, y);
-	  return allocp;
+	  set_heapp(allocp);
+	  return;
 	} else {
 	  x = temp;
 	  temp = temp1;
@@ -445,7 +448,8 @@
 	y = temp;
       }
       derefone(x) = y;		/* this also handles x==y cases */
-      return allocp;
+      set_heapp(allocp);
+      return;
     }
   }
 
@@ -454,11 +458,13 @@
     q temp = derefone(y);
     if (temp == y) { /* y is undef cell */
       derefone(y) = x;
-      return allocp;
+      set_heapp(allocp);
+      return;
     } else {
       if(isref(temp) && derefone(temp) == y) {
 	enqueue_unify_goal(x, y);
-	return allocp;
+	set_heapp(allocp);
+	return;
       }
     }
     y = temp;
@@ -468,7 +474,7 @@
   if (x != y) {
     enqueue_unify_goal(x, y);
   } 
-  return allocp;
+  set_heapp(allocp);
 }
 
 extern q*
@@ -540,16 +546,17 @@
   return do_unify(allocp, x, y);
 }
 
-extern q*
-do_shallow_unify_value(allocp, x, y)
-     q * allocp;
+extern void
+do_shallow_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:
@@ -557,22 +564,29 @@
       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(resume_goals(allocp, temp, y));
+	  return;
 	} else {
 	  x = temp;
 	  temp = temp1;
 	  goto again;
 	}
       } else {
-	return do_shallow_unify(allocp, temp1, y);
+	set_heapp(allocp);
+	do_shallow_unify(temp1, y);
+	return;
       }
     } else {
-      return do_shallow_unify(allocp, temp, y);
+      set_heapp(allocp);
+      do_shallow_unify(temp, y);
+      return;
     }
   }
-  return do_shallow_unify(allocp, x, y);
+  set_heapp(allocp);
+  do_shallow_unify(x, y);
 }
 
 extern q*
