diff -ruN klic-3.003-2002-02-26/include/klic/struct.h klic-3.003-2002-02-26a/include/klic/struct.h
--- klic-3.003-2002-02-26/include/klic/struct.h	Mon Feb 25 17:59:28 2002
+++ klic-3.003-2002-02-26a/include/klic/struct.h	Tue Feb 26 12:32:09 2002
@@ -184,7 +184,6 @@
 /* Global Variables */
 
 #define current_queue	(glbl->current_queue0)
-#define resumed_goals	(glbl->resumed_goals0)
 #define heaplimit	(glbl->heaplimit0)
 #define interrupt_off   (glbl->interrupt_off0)
 #define generic_arg	(glbl->generic_arg0)
@@ -196,7 +195,6 @@
   /* First four items are accessed frequently */
   q* volatile heaplimit0;	/* copy of real_heaplimit or 0 */
   struct goalrec* current_queue0; /* queue for current priority */
-  struct goalrec* resumed_goals0; /* spontaneous goals during reduction */
   /* The rest are not accessed as often */
   volatile long interrupt_off0;
 
@@ -265,6 +263,8 @@
 
 /* runtime/intrpt.c */
 extern void set_higher_priority_goal(void);
+extern void reset_resumed_goals(void);
+extern void add_resumed_goal(struct goalrec* goal);
 
 /* runtime/kmain.c */
 extern unsigned long heapsize(void);
diff -ruN klic-3.003-2002-02-26/runtime/bb.c klic-3.003-2002-02-26a/runtime/bb.c
--- klic-3.003-2002-02-26/runtime/bb.c	Mon Jan 21 20:55:25 2002
+++ klic-3.003-2002-02-26a/runtime/bb.c	Tue Feb 26 13:21:08 2002
@@ -5,6 +5,7 @@
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
 
+#include <stdio.h>  /* NULL */
 #include <klic/basic.h>  /* fatalf */
 #include <klic/struct.h>
 #include <klic/primitives.h>
@@ -68,11 +69,10 @@
       }							\
     }							\
   }							\
-  builtin_3_type_error(x, y, &pred, name);		\
+  builtin_type_error(name); \
  suspend_x:						\
-  return suspend_builtin_3(x, x, y, &pred);		\
  suspend_y:						\
-  return suspend_builtin_3(y, x, y, &pred);		\
+  return suspend_builtin(&pred, 3, x, y); \
 }
 
 #define builtin_body_2(macro_body, pred, name)		\
@@ -105,9 +105,9 @@
       }							\
     }							\
   }							\
-  builtin_2_type_error(x, &pred, name);			\
+  builtin_type_error(name); \
  suspend_x:						\
-  return suspend_builtin_2(x, &pred);			\
+  return suspend_builtin(&pred, 2, x, NULL); \
 }
 
 static void
@@ -115,71 +115,32 @@
      struct goalrec *goal;
 {
   declare_globals;
-  struct goalrec *rsmg = resumed_goals;
-  if (rsmg == 0) {
-    rsmg = goal;
-    goal->next = goal;
-  } else {
-    goal->next = rsmg->next;
-    rsmg->next = goal;
-  }
-  resumed_goals = rsmg;
-  heaplimit = 0;
+  add_resumed_goal(goal);
+  heaplimit = NULL;
 }
 
 static q
-suspend_builtin_3(v, x, y, pred)
-     q v, x, y;
-     const struct predicate* pred;
+suspend_builtin(const struct predicate* pred, int i, q x, q y)
 {
   declare_globals;
-  struct goalrec *goal;
+  struct goalrec* goal;
   q z;
-  heapalloc(goal, sizeof(struct goalrec)/sizeof(q)+3, (struct goalrec *));
-  z = makeref(&goal->args[2]);
+  heapalloc(goal, sizeof(struct goalrec)/sizeof(q)+i, (struct goalrec*));
+  i--;
   goal->pred = pred;
   goal->args[0] = x;
-  goal->args[1] = y;
-  goal->args[2] = z;
-  enqueue_as_resumed(goal);
-  return z;
-}
-
-static q
-suspend_builtin_2(v, pred)
-     q v;
-     const struct predicate* pred;
-{
-  declare_globals;
-  struct goalrec *goal = 0;
-  q z;
-  heapalloc(goal, sizeof(struct goalrec)/sizeof(q)+2, (struct goalrec *));
-  z = makeref(&goal->args[1]);
-  goal->pred = pred;
-  goal->args[0] = v;
-  goal->args[1] = z;
+  if( i == 2 ) goal->args[1] = y;
+  goal->args[i] = z = makeref(&goal->args[i]);
   enqueue_as_resumed(goal);
   return z;
 }
 
 static void
-builtin_3_type_error(x, y, pred, name)
-     q x, y;
-     struct predicate *pred;
-     char *name;
+builtin_type_error(char* name)
 {
   fatalf("Argument type error in builtin predicate: %s\n", name);
 }
 
-static void
-builtin_2_type_error(x, pred, name)
-     q x;
-     struct predicate *pred;
-     char *name;
-{
-  fatalf("Argument type error in builtin predicate %s", name);
-}
-
 extern q
 bblt_add_3(x, y)
   builtin_body_3(bblt_add_no_check,
@@ -286,10 +247,9 @@
   return z;
 
  type_error:
-  builtin_2_type_error(x,
-    predicate_floating__arithmetics_xfloating__point__to__integer_2,
-		       "fix/2");
+  builtin_type_error("fix/2");
  suspend_x:
-  return suspend_builtin_2(x,
-    &predicate_floating__arithmetics_xfloating__point__to__integer_2);
+  return suspend_builtin
+    (&predicate_floating__arithmetics_xfloating__point__to__integer_2,
+      2, x, NULL );
 }
diff -ruN klic-3.003-2002-02-26/runtime/faisus.c klic-3.003-2002-02-26a/runtime/faisus.c
--- klic-3.003-2002-02-26/runtime/faisus.c	Mon Feb 25 16:08:27 2002
+++ klic-3.003-2002-02-26a/runtime/faisus.c	Tue Feb 26 12:33:52 2002
@@ -186,14 +186,7 @@
     /*   - A higher priority goal got ready for execution */
     /*   - Garbage collection required */
     /* In such cases, the interrupted goal is pushed down to the queue. */
-    struct goalrec* rsmg = resumed_goals;
-    if (rsmg == NULL) {
-      goal->next = goal;
-    } else {
-      goal->next = rsmg->next;
-      rsmg->next = goal;
-    }
-    resumed_goals = goal;
+    add_resumed_goal(goal);
     set_heapp(allocp);
     return;
   } else if (reasonp == reasons) {
diff -ruN klic-3.003-2002-02-26/runtime/intrpt.c klic-3.003-2002-02-26a/runtime/intrpt.c
--- klic-3.003-2002-02-26/runtime/intrpt.c	Mon Feb 25 17:46:10 2002
+++ klic-3.003-2002-02-26a/runtime/intrpt.c	Tue Feb 26 12:35:33 2002
@@ -40,19 +40,32 @@
 int sigint_interrupt = 0;
 
 static int higher_priority_goal0;
+static struct goalrec* resumed_goals0; /* spontaneous goals during reduction */
+
 extern void set_higher_priority_goal(void){ higher_priority_goal0 = !0; }
+extern void reset_resumed_goals(void){ resumed_goals0 = NULL; }
+extern void
+add_resumed_goal(struct goalrec* goal){
+  if( resumed_goals0 == NULL ){
+    goal->next = goal;
+    resumed_goals0 = goal;
+  }else{
+    goal->next = resumed_goals0->next;
+    resumed_goals0->next = goal;
+  }
+}
 
 static struct goalrec*
 enqueue_resumed_goals(qp)
   struct goalrec* qp;
 {
   declare_globals;
-  struct goalrec* rsmg = resumed_goals;
+  struct goalrec* rsmg = resumed_goals0;
   if( rsmg != NULL ){
     struct goalrec* newqp = rsmg->next;
     rsmg->next = qp;
     qp = newqp;
-    resumed_goals = NULL;
+    resumed_goals0 = NULL;
     if( interrupt_off ) heaplimit = real_heaplimit();
   }
   return qp;
diff -ruN klic-3.003-2002-02-26/runtime/kmain.c klic-3.003-2002-02-26a/runtime/kmain.c
--- klic-3.003-2002-02-26/runtime/kmain.c	Mon Feb 25 17:36:18 2002
+++ klic-3.003-2002-02-26a/runtime/kmain.c	Tue Feb 26 12:36:06 2002
@@ -388,7 +388,7 @@
 	(void) enqueue_goal(NULL, HIGHESTPRIO-1, qp, glbl);
 
       current_queue = get_top_priority_queue();
-      resumed_goals = 0;
+      reset_resumed_goals();
 
 #ifdef DIST
       init_dist_signal_setup();
diff -ruN klic-3.003-2002-02-26/runtime/sched.c klic-3.003-2002-02-26a/runtime/sched.c
--- klic-3.003-2002-02-26/runtime/sched.c	Mon Feb 25 17:46:29 2002
+++ klic-3.003-2002-02-26a/runtime/sched.c	Tue Feb 26 12:38:02 2002
@@ -266,17 +266,7 @@
   ng->args[k+1] = prio;
   ng->args[k+2] = (is_relative ? makeint(1) : makeint(0));
   ng->pred = &wait_prio_preds[gp->pred->arity];
-  {
-    struct goalrec* rsmg = resumed_goals;
-    if( rsmg == 0 ){
-      rsmg = ng;
-      ng->next = ng;
-    }else{
-      ng->next = rsmg->next;
-      rsmg->next = ng;
-    }
-    resumed_goals = rsmg;
-  }
+  add_resumed_goal(ng);
   heaplimit = 0;
   return qp;
 }
@@ -342,17 +332,7 @@
   ng->args[k] = makecons(gp->pred);
   ng->args[k+1] = penum;
   ng->pred = &wait_penum_preds[gp->pred->arity];
-  {
-    struct goalrec* rsmg = resumed_goals;
-    if( rsmg == NULL ){
-      rsmg = ng;
-      ng->next = ng;
-    }else{
-      ng->next = rsmg->next;
-      rsmg->next = ng;
-    }
-    resumed_goals = rsmg;
-  }
+  add_resumed_goal(ng);
   heaplimit = 0;
   return qp;
 }
diff -ruN klic-3.003-2002-02-26/runtime/unify.c klic-3.003-2002-02-26a/runtime/unify.c
--- klic-3.003-2002-02-26/runtime/unify.c	Mon Feb 25 18:10:38 2002
+++ klic-3.003-2002-02-26a/runtime/unify.c	Tue Feb 26 12:38:46 2002
@@ -63,13 +63,7 @@
      struct goalrec *gp;
 {
   declare_globals;
-  if (resumed_goals == 0) {
-    resumed_goals = gp;
-    gp->next = gp;
-  } else {
-    gp->next = resumed_goals->next;
-    resumed_goals->next = gp;
-  }
+  add_resumed_goal(gp);
   heaplimit = 0;
 }
 
