diff -ruN klic-3.003-2002-01-06a/runtime/kmain.c klic-3.003-2002-01-06b/runtime/kmain.c
--- klic-3.003-2002-01-06a/runtime/kmain.c	Sun Jan  6 11:57:59 2002
+++ klic-3.003-2002-01-06b/runtime/kmain.c	Sun Jan  6 15:18:16 2002
@@ -23,6 +23,7 @@
 #include <stdio.h>
 #include <setjmp.h>
 #include <errno.h>
+
 #ifdef USESIG
 #include <signal.h>
 #endif
@@ -47,9 +48,82 @@
 q* gc_exp_table();
 q* gc_decode_stack();
 q* scan_imp_table();
-#endif
+#endif  /* DIST */
 
 #include "options.h"
+
+static long num_pes;
+static double max_a_ratio;
+static unsigned long h_size;
+static unsigned long max_h_size;
+static unsigned long inc_size;
+static int verbose;
+extern int start_tracing;
+extern int count_suspension;
+
+#ifdef USETIMER
+static unsigned long dl_det_interval;
+#endif /*USETIMER*/
+
+const struct opttable opttable[] = {
+#ifdef USER_OPTIONS
+    USER_OPTIONS
+#endif
+#ifdef POLLING_OPTIONS
+    POLLING_OPTIONS
+#endif
+#ifdef PARALLEL
+    "p",        (union all_type*) &num_pes, ARG_SIZE,
+    "-p <# of workers>: number of worker processes ",
+#endif
+#ifdef DIST_OPTIONS
+    DIST_OPTIONS
+#endif
+#if defined(DIST) && defined(SHM_DIST)
+    "B",	(union all_type*) &shared_buffer_size, ARG_SIZE,
+    "-B <communication buffer size>",
+#endif
+#ifdef SHM
+    "S",        (union all_type*) &SHM_SIZE, ARG_SIZE,
+    "-S <shared-memory heap size>: shared-memory heap size, never expand",
+
+    "D",        (union all_type*) &Disp_child, ARG_SET,
+    "-D: display child process number on UNIX",
+#endif
+    "a",	(union all_type*) &max_a_ratio, ARG_DOUBLE,
+    "-a <ratio>: active cell ratio to triger heap extension\n" \
+    "\t  <ratio> should be a floating point number >0 and <1",
+
+    "h",	(union all_type*) &h_size, ARG_SIZE,
+    "-h <initial heap size>: initial size of heap",
+
+    "H",	(union all_type*) &max_h_size, ARG_SIZE,
+    "-H <max heap size>: maximum possible heap size",
+
+    "i",	(union all_type*) &inc_size, ARG_SIZE,
+    "-i <increment>: gap between heap top and bottom\n" \
+    "\t  for -h, -H and -i, 32k means 32KW and 2m means 2MW",
+
+    "g",	(union all_type*) &measure_gc, ARG_SET,
+    "-g: set garbage collection measurement on",
+
+    "v",	(union all_type*) &verbose, ARG_SET,
+    "-v: display KLIC runtime version",
+#ifdef DEBUGLIB
+    "t",	(union all_type*) &start_tracing, ARG_SET,
+    "-t: start execution with tracing",
+
+    "s",	(union all_type*) &count_suspension, ARG_SET,
+    "-s: count suspension",
+#endif /* DEBUGLIB */
+#ifdef USETIMER
+    "deadlock-detection-interval",
+		(union all_type*) &dl_det_interval, ARG_SIZE,
+    "-deadlock-detection-interval <interval>:\n" \
+    "\t  specify deadlock detect interval in micro sec.\n" \
+    "\t  Set <interval> to 0 to supress early deadlock detection completely.",
+#endif /*USETIMER*/
+    0, 0 };
 
 #ifdef DEBUGLIB
 #include "trace.h"  /* trace_goal */
diff -ruN klic-3.003-2002-01-06a/runtime/options.h klic-3.003-2002-01-06b/runtime/options.h
--- klic-3.003-2002-01-06a/runtime/options.h	Fri Dec 28 13:46:47 2001
+++ klic-3.003-2002-01-06b/runtime/options.h	Sun Jan  6 15:19:24 2002
@@ -8,6 +8,13 @@
 #ifndef _KLIC_OPTIONS_H_
 #define _KLIC_OPTIONS_H_
 
+/* not copied when spawned */
+#define ARG_SHOULD_NOT_COPY(X)	((int)(X) >= (int)ARG_NOT_USED)
+
+#define ARG_ORIGINAL_TYPE(X) \
+  ((enum argtype) \
+    (ARG_SHOULD_NOT_COPY(X) ? (int)(X)-(int)ARG_NOT_USED : (int)(X)))
+
 union all_type {
     int i;
     long l;
@@ -24,20 +31,6 @@
     ARG_NOT_USED
 };
 
-extern const struct opttable opttable[];
-
-/* runtime/options.c */
-extern char* parse_opts(const struct opttable* opttbl, int* acp, char*** avp);
-
-/* not copied when spawned */
-#define ARG_SHOULD_NOT_COPY(X)	((int)(X) >= (int)ARG_NOT_USED)
-#define ARG_NOT_COPIED(X) \
-  ((enum argtype) ((int)(X) + (int)ARG_NOT_USED))
-
-#define ARG_ORIGINAL_TYPE(X) \
-  ((enum argtype) \
-    (ARG_SHOULD_NOT_COPY(X) ? (int)(X)-(int)ARG_NOT_USED : (int)(X)))
-
 struct opttable {
     char* opt_str;
     union all_type* opt_dest;
@@ -45,82 +38,9 @@
     char* opt_usage;
 };
 
-#ifndef MAIN
 extern const struct opttable opttable[];
-#else  /* MAIN */
-static long num_pes;
-static double max_a_ratio;
-static unsigned long h_size;
-static unsigned long max_h_size;
-static unsigned long inc_size;
-static int verbose;
-extern int start_tracing;
-extern int count_suspension;
-#ifdef USETIMER
-static unsigned long dl_det_interval;
-#endif /*USETIMER*/
-const struct opttable opttable[] = {
-#ifdef USER_OPTIONS
-    USER_OPTIONS
-#endif
-#ifdef POLLING_OPTIONS
-    POLLING_OPTIONS
-#endif
-#ifdef PARALLEL
-    "p",        (union all_type*) &num_pes, ARG_SIZE,
-    "-p <# of workers>: number of worker processes ",
-#endif
-#ifdef DIST_OPTIONS
-    DIST_OPTIONS
-#endif
-#ifdef DIST
-#ifdef SHM_DIST
-    "B",	(union all_type*) &shared_buffer_size, ARG_SIZE,
-    "-B <communication buffer size>",
-#endif
-#endif
-#ifdef SHM
-    "S",        (union all_type*) &SHM_SIZE, ARG_SIZE,
-    "-S <shared-memory heap size>: shared-memory heap size, never expand",
-
-    "D",        (union all_type*) &Disp_child, ARG_SET,
-    "-D: display child process number on UNIX",
-
-#endif
-    "a",	(union all_type*) &max_a_ratio, ARG_DOUBLE,
-    "-a <ratio>: active cell ratio to triger heap extension\n"
-    "\t  <ratio> should be a floating point number >0 and <1",
-
-    "h",	(union all_type*) &h_size, ARG_SIZE,
-    "-h <initial heap size>: initial size of heap",
-
-    "H",	(union all_type*) &max_h_size, ARG_SIZE,
-    "-H <max heap size>: maximum possible heap size",
-
-    "i",	(union all_type*) &inc_size, ARG_SIZE,
-    "-i <increment>: gap between heap top and bottom\n"
-    "\t  for -h, -H and -i, 32k means 32KW and 2m means 2MW",
-
-    "g",	(union all_type*) &measure_gc, ARG_SET,
-    "-g: set garbage collection measurement on",
-
-    "v",	(union all_type*) &verbose, ARG_SET,
-    "-v: display KLIC runtime version",
-#ifdef DEBUGLIB
-    "t",	(union all_type*) &start_tracing, ARG_SET,
-    "-t: start execution with tracing",
-
-    "s",	(union all_type*) &count_suspension, ARG_SET,
-    "-s: count suspension",
-#endif /* DEBUGLIB */
-#ifdef USETIMER
-    "deadlock-detection-interval",
-		(union all_type*) &dl_det_interval, ARG_SIZE,
-    "-deadlock-detection-interval <interval>:\n"
-    "\t  specify deadlock detect interval in micro sec.\n"
-    "\t  Set <interval> to 0 to supress early deadlock detection completely.",
-#endif /*USETIMER*/
-    0, 0 };
-#endif /* MAIN */
+
+/* runtime/options.c */
+extern char* parse_opts(const struct opttable* opttbl, int* acp, char*** avp);
 
 #endif /* _KLIC_OPTIONS_H_ */
diff -ruN klic-3.003-2002-01-06a/runtime/otbl.c klic-3.003-2002-01-06b/runtime/otbl.c
--- klic-3.003-2002-01-06a/runtime/otbl.c	Sat Dec 29 12:46:20 2001
+++ klic-3.003-2002-01-06b/runtime/otbl.c	Sun Jan  6 15:18:16 2002
@@ -7,109 +7,113 @@
 /*
   Object table
 */
+
 #include <klic/alloc.h>  /* register_after_gc_hook */
 #include <klic/basic.h>  /* fatal */
 #include <klic/struct.h>
 #include <klic/g_basic.h>
 #include <klic/g_methtab.h>
 
+extern char* calloc();
+
+#define OTBLBLKSIZE 100
+
 #define generic_deallocate(obj) (obj)->method_table->deallocate(obj)
 
 struct object_table {
   unsigned int type;
-  void *obj;
-  struct object_table *next;
+  void* obj;
+  struct object_table* next;
 };
 
-static int gc_hook_initialized = 0;
-
-#define OTBLBLKSIZE 100
+static struct object_table* tbl_root = NULL;
+static struct object_table* free_oent = NULL;
 
-static struct object_table *tbl_root = (struct object_table *)0;
+static Inline struct object_table*
+allocOtblBulk()
+{
+  int i;
+  struct object_table* ptr =
+    (struct object_table*) calloc(sizeof(struct object_table), OTBLBLKSIZE);
+  struct object_table* top = ptr;
 
-static struct object_table *free_oent = (struct object_table *)0;
+  if( ptr == NULL )
+    fatal("Memory exhausted allocating object table");
 
-static Inline struct object_table *
-allocOtblBulk() {
-  int i;
-  extern char *calloc();
-  struct object_table *ptr =
-    (struct object_table *)calloc(sizeof(struct object_table), OTBLBLKSIZE);
-  struct object_table *top = ptr;
-
-  if(!ptr)
-    fatal("Memory exhosted allocating object table");
-  
-  for(i=0; i<OTBLBLKSIZE; i++, ptr++) {
-    ptr->next = (ptr+1);
+  for( i=0; i<OTBLBLKSIZE; i++, ptr++ ){
+    ptr->next = ptr+1;
   }
 
-  (ptr-1)->next = (struct object_table *)0;
+  (ptr-1)->next = NULL;
 
-  return(top);
+  return top;
 }
 
-static Inline struct object_table *
-allocOtblEnt() {
-  struct object_table *ent = free_oent;
-  if(!ent)
-    ent = allocOtblBulk();
+static Inline struct object_table*
+allocOtblEnt()
+{
+  struct object_table* ent;
+  ent = (free_oent != NULL ? free_oent : allocOtblBulk());
 
   free_oent = ent->next;
-  return(ent);
+  return ent;
 }
 
-static q *deallocate_garbage(allocp)
-     q *allocp;
+static q*
+deallocate_garbage(allocp)
+  q* allocp;
 {
-  struct object_table *tbl = tbl_root;
-  struct object_table *newtbl = (struct object_table *)0;
-  struct object_table **ptr = &newtbl;
-  struct object_table *free = free_oent;
-
-  while(tbl) {
-    struct object_table *next = tbl->next;
-    struct data_object *obj = tbl->obj;
-    q newplace = (q)(obj->method_table);
+  struct object_table* tbl = tbl_root;
+  struct object_table* newtbl = (struct object_table *)0;
+  struct object_table** ptr = &newtbl;
+  struct object_table* free = free_oent;
+
+  while( tbl != NULL ){
+    struct object_table* next = tbl->next;
+    struct data_object* obj = tbl->obj;
+    q newplace = (q) obj->method_table;
 
-    if(!isstruct(newplace)) { /* the object is garbage */
+    if( !isstruct(newplace) ){  /* the object is garbage */
       int retval;
-      switch(tbl->type) {
+      switch( tbl->type ){
       case G_CONSUMER:
-	retval = generic_deallocate((struct consumer_object *)(obj));
+	retval = generic_deallocate((struct consumer_object*) obj);
 	break;
       case G_GENERATOR:
-	retval = generic_deallocate((struct generator_object *)(obj));
+	retval = generic_deallocate((struct generator_object*) obj);
 	break;
-      default: /* data object */
+      default:  /* data object */
 	retval = generic_deallocate(obj);
       }
-      if(retval) {
+      if( retval ){
 	fatal("Close method has not been supported\n");
       }
       tbl->next = free;
       free = tbl;
-    } else {
+    }else{
       tbl->obj = functorp(newplace);
       *ptr = tbl;
       ptr = &(tbl->next);
     }
     tbl = next;
   }
-  *ptr = (struct object_table *)0;
+  *ptr = NULL;
   tbl_root = newtbl;
   free_oent = free;
-  return(allocp);
+  return allocp;
 }
 
-void register_for_deallocation(obj, type)
-     void *obj;
-     int type;
+extern void
+register_for_deallocation(obj, type)
+  void* obj;
+  int type;
 {
-  struct object_table *newent = allocOtblEnt();
-  struct object_table *tbl = tbl_root;
+  static int gc_hook_initialized = 0;
+
+  struct object_table* newent = allocOtblEnt();
+  struct object_table* tbl = tbl_root;
 
-  if(!gc_hook_initialized) {
+  if( !gc_hook_initialized ){
     register_after_gc_hook(deallocate_garbage);
     gc_hook_initialized = 1;
   }
diff -ruN klic-3.003-2002-01-06a/runtime/pipedio.c klic-3.003-2002-01-06b/runtime/pipedio.c
--- klic-3.003-2002-01-06a/runtime/pipedio.c	Tue Jan  1 14:17:47 2002
+++ klic-3.003-2002-01-06b/runtime/pipedio.c	Sun Jan  6 15:18:16 2002
@@ -4,7 +4,9 @@
 %   (C)1996, 1997, 1998, 1999 Japan Information Processing Development Center
 %       (Read COPYRIGHT-JIPDEC for detailed information.)
 ----------------------------------------------------------- */
+
 #include <klic/config.h>
+
 #ifdef XTERM
 #include <sys/types.h>
 #include <sys/socket.h>
@@ -14,26 +16,29 @@
 #include <termios.h>
 #include <unistd.h>
 
+extern void* malloc();
+
 #define BUFFER_SIZE 1024
 
+static void
 loop(in, out)
-     int in, out;
+  int in, out;
 {
   char buf[BUFFER_SIZE];
   long bytes;
  again:
-  while ((bytes = read(in, buf, BUFFER_SIZE)) != 0) {
+  while( (bytes = read(in, buf, BUFFER_SIZE)) != 0 ){
     long written = 0;
-    if (bytes == -1) {
-      if (errno == EINTR) {
+    if( bytes == -1 ){
+      if( errno == EINTR ){
 	goto again;
-      } else {
+      }else{
 	exit(1);
       }
     }
-    do {
+    do{
       written += write(out, &buf[written], bytes-written);
-    } while (written < bytes);
+    }while( written < bytes );
   }
 }
 
@@ -65,6 +70,7 @@
 #define CTRL_Y		('Y'-'@')
 #define CTRL_Z		('Z'-'@')
 
+static void
 set_terminal_parameters()
 {
   struct termios params;
@@ -83,19 +89,19 @@
   tcsetattr(fileno(stdin), TCSANOW, &params);
 }
 
+extern int
 main(argc, argv)
-     int argc;
-     char **argv;
+  int argc;
+  char** argv;
 {
-  char *sockname;
+  char* sockname;
   int insock, outsock;
   int infd, outfd;
-  struct sockaddr *addr;
+  struct sockaddr* addr;
   int addr_size;
   fd_set readfds;
-  void *malloc();
 
-  if (argc != 2) exit(1);
+  if( argc != 2 ) exit(1);
 
   set_terminal_parameters();
 
@@ -103,16 +109,16 @@
   insock = socket(AF_UNIX, SOCK_STREAM, 0);
   outsock = socket(AF_UNIX, SOCK_STREAM, 0);
   addr_size = sizeof(struct sockaddr) + strlen(sockname) + 1;
-  addr = (struct sockaddr *)malloc(addr_size);
+  addr = (struct sockaddr*) malloc(addr_size);
   addr->sa_family = PF_UNIX;
   strcpy(addr->sa_data, sockname);
   connect(insock, addr, addr_size);
   connect(outsock, addr, addr_size);
   free(addr);
-  if (fork() == 0) {
+  if( fork() == 0 ){
     close(outsock);
     loop(insock, fileno(stdout));
-  } else {
+  }else{
     close(insock);
     loop(fileno(stdin), outsock);
     wait(0);
@@ -120,6 +126,10 @@
   exit(0);
 }
 
-#else
-main() { return 1; }
+#else  /* not XTERM */
+extern int
+main(argc, argv)
+  int argc;
+  char** argv;
+{ return 1; }
 #endif
