diff -ruN klic-3.003-2002-02-06/compiler/klicdb.c klic-3.003-2002-02-06a/compiler/klicdb.c
--- klic-3.003-2002-02-06/compiler/klicdb.c	Wed Feb  6 15:50:18 2002
+++ klic-3.003-2002-02-06a/compiler/klicdb.c	Wed Feb  6 16:16:45 2002
@@ -517,7 +517,7 @@
     (void) fprintf(atomh,
       "#include <klic/atomstuffs.h>  /* ATOMNUMBERBASE */\n\n");
     (void) fprintf(atomc,
-      "#include <klic/atomstuffs.h>  /* atomname */\n" \
+      "#include <klic/atomstuffs.h>  /* init_atomname */\n" \
       "#include <klic/basic.h>\n\n" \
       "unsigned char* const init_atomname[] = {\n" );
   }
diff -ruN klic-3.003-2002-02-06/include/klic/atomstuffs.h klic-3.003-2002-02-06a/include/klic/atomstuffs.h
--- klic-3.003-2002-02-06/include/klic/atomstuffs.h	Wed Feb  6 15:50:54 2002
+++ klic-3.003-2002-02-06a/include/klic/atomstuffs.h	Wed Feb  6 16:35:58 2002
@@ -14,10 +14,10 @@
 
 /* atom.c */
 extern unsigned char* const init_atomname[];
-extern unsigned char** atomname;
+extern unsigned char* atomname(unsigned long id);
 
 #define ATOMNUMBERBASE 2
-#define functoratomname(f)  (atomname[functoratom(f) - ATOMNUMBERBASE])
-#define namestringof(a)  (atomname[symval(a) - ATOMNUMBERBASE])
+#define functoratomname(f)  (atomname (functoratom (f)))
+#define namestringof(a)  (atomname (symval (a)))
 
 #endif /* _KLIC_ATOMSTUFFS_H_ */
diff -ruN klic-3.003-2002-02-06/runtime/debug.c klic-3.003-2002-02-06a/runtime/debug.c
--- klic-3.003-2002-02-06/runtime/debug.c	Sun Jan 13 12:30:53 2002
+++ klic-3.003-2002-02-06a/runtime/debug.c	Wed Feb  6 16:37:52 2002
@@ -18,7 +18,7 @@
 #include <klic/primitives.h>
 #include <klic/unify.h>
 #include <klic/index.h>
-#include <klic/atomstuffs.h>  /* atomname, ATOMNUMBERBASE */
+#include <klic/atomstuffs.h>  /* atomname */
 #include <klic/functorstuffs.h>  /* functors, arities, FUNCTORNUMBERBASE */
 
 #ifdef DIST
@@ -290,7 +290,7 @@
       case 'F':
 	fprintf_func(out, "%s/%d",
 #ifdef DEBUGLIB
-		atomname[functors[*argp-FUNCTORNUMBERBASE] - ATOMNUMBERBASE],
+		atomname(functors[*argp - FUNCTORNUMBERBASE]),
 #else
 		"???",
 #endif
diff -ruN klic-3.003-2002-02-06/runtime/newatom.c klic-3.003-2002-02-06a/runtime/newatom.c
--- klic-3.003-2002-02-06/runtime/newatom.c	Wed Feb  6 15:50:18 2002
+++ klic-3.003-2002-02-06a/runtime/newatom.c	Wed Feb  6 16:34:56 2002
@@ -10,7 +10,7 @@
 #include <klic/primitives.h>  /* malloc_check */
 #include <klic/unify.h>
 #include <klic/index.h>
-#include <klic/atomstuffs.h>  /* atomname, ATOMNUMBERBASE */
+#include <klic/atomstuffs.h>  /* ATOMNUMBERBASE */
 #include <klic/functorstuffs.h>  /* functors, arities, FUNCTORNUMBERBASE */
 #include <klic/newatom.h>
 
@@ -27,7 +27,7 @@
 extern unsigned long generic_string_size();
 extern unsigned char* convert_klic_string_to_c_string();
 
-unsigned char** atomname = (unsigned char**) init_atomname;
+static unsigned char** atomnames = (unsigned char**) init_atomname;
 
 struct atomhashtable{
   long atomid;
@@ -115,7 +115,7 @@
 
   index = atomhp->table[hashvalue] - 1;
   if( index >= 0 ){
-    while( strcmp((char*) atomname[index], (char*) name) != 0 ){
+    while( strcmp((char*) atomnames[index], (char*) name) != 0 ){
       long index0 = nextatom[index];
       if( index0 == -1 ){
 	nextatom[index] = i;
@@ -181,13 +181,13 @@
       (long*) malloc_check((unsigned) (sizeof(long) * numberOfAtoms));
   }else{
     atomhp->nametablesize = 1;
-    atomname = (unsigned char**) malloc_check(sizeof(char*));
+    atomnames = (unsigned char**) malloc_check(sizeof(char*));
     nextatom = (long*) malloc_check(sizeof(long));
   }
 
   for( i = 0; i < Hashsize; i++ ){ atomhp->table[i] = 0; }
   for( i = 0; i < atomhp->nametablesize; i++ ){ nextatom[i] = -1; }
-  for( i = 0; i < numberOfAtoms; i++ ){ enter_old_atom(i, atomname[i]); }
+  for( i = 0; i < numberOfAtoms; i++ ){ enter_old_atom(i, atomnames[i]); }
 }
 
 static void
@@ -239,7 +239,7 @@
  again:
   index = atomhp->table[hashvalue] - 1;
   if( index >= 0 ){
-    while( (strcmp((char*) atomname[index], (char*) name)) ){
+    while( (strcmp((char*) atomnames[index], (char*) name)) ){
       index0 = nextatom[index];
       if( index0 == -1 ){
 	if( atomhp->atomid +1 == atomhp->nametablesize ) goto expand;
@@ -250,7 +250,7 @@
 	  nameareap = namearea;
 	}
         strcpy((char*) nameareap, (char*) name);
-	atomname[atomhp->atomid] = nameareap;
+	atomnames[atomhp->atomid] = nameareap;
         nameareap += namelen;
 	*nameareap++ = '\0';
 	nextatom[atomhp->atomid] = -1;
@@ -276,7 +276,7 @@
       }
       atomhp->table[hashvalue] = ++(atomhp->atomid) + 1;
       strcpy((char*) nameareap, (char*) name);
-      atomname[atomhp->atomid] = nameareap;
+      atomnames[atomhp->atomid] = nameareap;
       nameareap += strlen((char*) name) + 1;
       nextatom[atomhp->atomid] = -1;
     }
@@ -289,25 +289,25 @@
  expand:
   {
     declare_globals;
-    unsigned char** newatomname;
+    unsigned char** newatomnames;
     long* newnextatom;
     int i;
 #ifdef SHM
-    if( is_shma(atomname) ) abend("Can't expand on this version.");
+    if( is_shma(atomnames) ) abend("Can't expand on this version.");
 #endif
-    newatomname = (unsigned char**)
+    newatomnames = (unsigned char**)
       malloc_check((atomhp->nametablesize) * sizeof(char*)*2);
     newnextatom = (long*)
       malloc_check((atomhp->nametablesize) * sizeof(long)*2);
     for( i = 0; i < atomhp->nametablesize; i++ ){
-      newatomname[i] = atomname[i];
+      newatomnames[i] = atomnames[i];
       newnextatom[i] = nextatom[i];
     }
     for( i = atomhp->nametablesize; i < 2*atomhp->nametablesize; i++ ){
       newnextatom[i] = -1;
     }
     atomhp->nametablesize = 2 * atomhp->nametablesize;
-    atomname = newatomname;
+    atomnames = newatomnames;
     nextatom = newnextatom;
   }
   goto again;
@@ -411,4 +411,16 @@
     nextfunctor = (long*) newnextfunctor;
   }
   goto again;
+}
+
+
+extern unsigned char*
+atomname(unsigned long id)
+{
+  unsigned long size =
+    (atomhp->nametablesize > 0 ? atomhp->nametablesize : initial_atoms);
+  unsigned long i = id - ATOMNUMBERBASE;
+
+  if (i >= size)
+    fatalf("atomname: id %d > %d", i, size);
+
+  return atomnames[i];
 }
