diff --git a/hat.cabal b/hat.cabal
--- a/hat.cabal
+++ b/hat.cabal
@@ -1,6 +1,6 @@
 
 name:                hat
-version:             2.9.1
+version:             2.9.2
 synopsis:            The Haskell tracer, generating and viewing Haskell execution traces
 description:
   hat-trans transforms Module.hs into Hat/Module.hs such that when the program is
@@ -17,7 +17,7 @@
   Although it should build on any operating system,
   most viewing tools use ASCII console escape sequences and they open xterms;
   hence they will only work well under Unix and X11.
-  Tested on MacOS X 10.9.5.
+  Tested on MacOS X 10.11.6.
 
   Installation:
 
@@ -189,7 +189,7 @@
   main-is:	     HatNonTerm.hs
   hs-source-dirs:    tools
   other-modules:     LowLevel, SExp, PrettyLibHighlight, HighlightStyle, Run, NonTermLib, CommonUI, Ident, SrcRef
-  build-depends:     base >=4.9, process >=1.1
+  build-depends:     base >=4.9, process >=1.1, directory >= 1.0
   extensions:	     ForeignFunctionInterface
   includes:	     art.h, ntohl.h
   include-dirs:	     include
diff --git a/tools/artutils.c b/tools/artutils.c
--- a/tools/artutils.c
+++ b/tools/artutils.c
@@ -88,6 +88,16 @@
   return buf.st_size;
 }
 
+/* myfread() is just like fread(), except if it fails reading everything, it
+ * aborts with an error message.
+ */
+void myfread(void* buf, int siz, int num, FILE* stream)
+{
+  if (fread(buf,siz,num,stream) != num) {
+    fprintf(stderr, "fread failed.\n");
+    exit(1);
+  }
+}
 
 /* freadAt() is just like fread(), except it seeks to a specific
  * file location first.  (Random Access)
@@ -140,7 +150,7 @@
 readFO (void)
 {
   FileOffset fo;
-  fread(&fo,sizeof(FileOffset),1,HatFileRandom);
+  myfread(&fo,sizeof(FileOffset),1,HatFileRandom);
   HIDE(fprintf(stderr,"readFO -> 0x%x\n",ntohl(fo));)
   return ntohl(fo);
 }
@@ -282,10 +292,10 @@
       case AtomConstructor:
           id = (Ident*)malloc(sizeof(Ident));
           modpos = readFO();
-          fread(&defnpos,sizeof(int),1,HatFileRandom);
-          fread(&defnposend,sizeof(int),1,HatFileRandom);
-          fread(&(id->fixity),sizeof(char),1,HatFileRandom);
-          fread(&(id->arity),sizeof(char),1,HatFileRandom);
+          myfread(&defnpos,sizeof(int),1,HatFileRandom);
+          myfread(&defnposend,sizeof(int),1,HatFileRandom);
+          myfread(&(id->fixity),sizeof(char),1,HatFileRandom);
+          myfread(&(id->arity),sizeof(char),1,HatFileRandom);
           id->idname       = readString();
           id->defnline     = ntohl(defnpos)/10000;
           id->defncolumn   = ntohl(defnpos)%10000;
@@ -353,9 +363,9 @@
     }
     sr = (SrcRef*)malloc(sizeof(SrcRef));
     modpos = readFO();
-    fread(&usepos,sizeof(int),1,HatFileRandom);
+    myfread(&usepos,sizeof(int),1,HatFileRandom);
     usepos = ntohl(usepos);
-    fread(&useposend,sizeof(int),1,HatFileRandom);
+    myfread(&useposend,sizeof(int),1,HatFileRandom);
     useposend = ntohl(useposend);
     readModuleAt(modpos, &modname, &(sr->srcname), &dummy);
     sr->line    = usepos/10000;
@@ -415,7 +425,7 @@
   parent = readFO();
   switch (lower5(c)) {
     case ExpChar:
-		{ fread(&c,sizeof(char),1,HatFileRandom);
+		{ myfread(&c,sizeof(char),1,HatFileRandom);
 		  if ((c>31) && (c!='\''))
 		    sprintf(buf,"'%c'",c);
 		  else switch(c) {
@@ -428,7 +438,7 @@
 		} break;
     case ExpInt:
 		{ int i;
-		  fread(&i,sizeof(int),1,HatFileRandom);
+		  myfread(&i,sizeof(int),1,HatFileRandom);
 		  sprintf(buf,"%d",ntohl(i));
 		  id->idname = strdup(buf);
 		} break;
@@ -437,8 +447,8 @@
 		} break;
     case ExpRat:
 		{ int i,j;
-		  fread(&i,sizeof(int),1,HatFileRandom);
-		  fread(&j,sizeof(int),1,HatFileRandom);
+		  myfread(&i,sizeof(int),1,HatFileRandom);
+		  myfread(&j,sizeof(int),1,HatFileRandom);
 		  sprintf(buf,"%d%%%d",ntohl(i),ntohl(j));
 		  id->idname = strdup(buf);
 		} break;
@@ -448,13 +458,13 @@
 		} break;
     case ExpFloat:
 		{ float f;
-		  fread(&f,sizeof(float),1,HatFileRandom);
+		  myfread(&f,sizeof(float),1,HatFileRandom);
 		  sprintf(buf,"%.6f",f);
 		  id->idname = strdup(buf);
 		} break;
     case ExpDouble:
 		{ double d;
-		  fread(&d,sizeof(double),1,HatFileRandom);
+		  myfread(&d,sizeof(double),1,HatFileRandom);
 		  sprintf(buf,"%.15f",d);
 		  id->idname = strdup(buf);
 		} break;
@@ -662,7 +672,7 @@
           HIDE(fprintf(stderr,"enter parent of 0x%x -> 0x%x\n",fo,parent);)
           readFO();				/* skip result */
 	  foExprs[0] = readFO();		/* get fun */
-	  fread(&arity,sizeof(unsigned char),1,HatFileRandom);
+	  myfread(&arity,sizeof(unsigned char),1,HatFileRandom);
 	  for (i=1; i<=arity; i++) {
 	    foExprs[i] = readFO();
           }
@@ -705,7 +715,7 @@
           parent = readFO();			/* get parent */
           HIDE(fprintf(stderr,"enter parent of 0x%x -> 0x%x\n",fo,parent);)
 	  foExprs[0] = readFO();		/* get fun */
-	  fread(&arity,sizeof(unsigned char),1,HatFileRandom);
+	  myfread(&arity,sizeof(unsigned char),1,HatFileRandom);
 	  for (i=1; i<=arity; i++) {
 	    foExprs[i] = readFO();
           }
@@ -1203,23 +1213,23 @@
         readFO();				/* skip parent */
         readFO();				/* skip result */
         readFO();				/* skip fun/constructor */
-        fread(&c,sizeof(char),1,HatFileRandom);	/* get arity */
+        myfread(&c,sizeof(char),1,HatFileRandom);	/* get arity */
         return (int)(c);
         break;
     case ExpValueApp:
         if (hasSrcPos(c)) { readFO(); }		/* skip usage position */
         readFO();				/* skip parent */
         readFO();				/* skip constructor */
-        fread(&c,sizeof(char),1,HatFileRandom);	/* get arity */
+        myfread(&c,sizeof(char),1,HatFileRandom);	/* get arity */
         return (int)c;
         break;
     case AtomConstructor:			/* only interested in fields */
         if (!hasFields(c)) { return 0; }
         readFO();				/* skip module */
-        { int x; fread(&x,sizeof(int),1,HatFileRandom); }
-        { int x; fread(&x,sizeof(int),1,HatFileRandom); }
-        { char x; fread(&x,sizeof(char),1,HatFileRandom); }
-        { char arity; fread(&arity,sizeof(char),1,HatFileRandom);
+        { int x; myfread(&x,sizeof(int),1,HatFileRandom); }
+        { int x; myfread(&x,sizeof(int),1,HatFileRandom); }
+        { char x; myfread(&x,sizeof(char),1,HatFileRandom); }
+        { char arity; myfread(&arity,sizeof(char),1,HatFileRandom);
           return (int)arity; }
         break;
     case Module:
@@ -1273,7 +1283,7 @@
         readFO();				/* skip result */
         ptr = readFO();				/* fun/constructor */
         if (n==0) return getResult(ptr,True);
-        fread(&c,sizeof(char),1,HatFileRandom);	/* get arity */
+        myfread(&c,sizeof(char),1,HatFileRandom);	/* get arity */
         if (n<=c) {
           for (i=1; i<n; i++) readFO();		/* skip other args */
           ptr = readFO();			/* get n'th arg */
@@ -1286,7 +1296,7 @@
         readFO();				/* skip parent */
         ptr = readFO();				/* fun/constructor */
         if (n==0) return ptr;	/* no result-chain - fun is already an atom */
-        fread(&c,sizeof(char),1,HatFileRandom);	/* get arity */
+        myfread(&c,sizeof(char),1,HatFileRandom);	/* get arity */
         if (n<=c) {
           for (i=1; i<n; i++) readFO();		/* skip other args */
           ptr = readFO();			/* get n'th arg */
@@ -1322,7 +1332,7 @@
         readFO();				/* skip result */
         ptr = readFO();				/* exp/constructor */
         if (n==0) return getResult(ptr,True);
-        fread(&c,sizeof(char),1,HatFileRandom);	/* get arity */
+        myfread(&c,sizeof(char),1,HatFileRandom);	/* get arity */
         if (n<=c) {
           for (i=0; i<c; i++) readFO();		/* skip binder labels */
           for (i=1; i<n; i++) readFO();		/* skip other bindees */
@@ -1380,7 +1390,7 @@
         readFO();				/* skip result */
         ptr = readFO();				/* fun/constructor */
         if (n==0) return ptr;
-        fread(&c,sizeof(char),1,HatFileRandom);	/* get arity */
+        myfread(&c,sizeof(char),1,HatFileRandom);	/* get arity */
         assert (n<=c);
         for (i=1; i<n; i++) readFO();		/* skip other args */
         ptr = readFO();		                /* get n'th arg */
@@ -1391,7 +1401,7 @@
         readFO();				/* skip parent */
         ptr = readFO();				/* fun/constructor */
         if (n==0) return ptr;
-        fread(&c,sizeof(char),1,HatFileRandom);	/* get arity */
+        myfread(&c,sizeof(char),1,HatFileRandom);	/* get arity */
         assert (n<=c);
         for (i=1; i<n; i++) readFO();		/* skip other args */
         ptr = readFO();			        /* get n'th arg */
@@ -1425,7 +1435,7 @@
         readFO();				/* skip result */
         ptr = readFO();				/* exp/constructor */
         if (n==0) return ptr;
-        fread(&c,sizeof(char),1,HatFileRandom);	/* get arity */
+        myfread(&c,sizeof(char),1,HatFileRandom);	/* get arity */
         assert (n<=c);
         for (i=0; i<c; i++) readFO();		/* skip binder labels */
         for (i=1; i<n; i++) readFO();		/* skip other bindees */
@@ -1490,7 +1500,7 @@
         readFO();				/* skip parent */
         readFO();				/* skip result */
         readFO();				/* skip exp/constructor */
-        fread(&c,sizeof(char),1,HatFileRandom);	/* get arity */
+        myfread(&c,sizeof(char),1,HatFileRandom);	/* get arity */
         if (n<=c) {
           for (i=1; i<n; i++) readFO();		/* skip other labels */
           ptr = readFO();			/* get n'th label */
@@ -1507,10 +1517,10 @@
     case AtomConstructor:
         if (hasFields(c)) {
           readFO();				/* skip module ptr */
-          { int x; fread(&x,sizeof(int),1,HatFileRandom); }
-          { int x; fread(&x,sizeof(int),1,HatFileRandom); }
-          { char x; fread(&x,sizeof(char),1,HatFileRandom); }
-          { char arity; fread(&arity,sizeof(char),1,HatFileRandom);
+          { int x; myfread(&x,sizeof(int),1,HatFileRandom); }
+          { int x; myfread(&x,sizeof(int),1,HatFileRandom); }
+          { char x; myfread(&x,sizeof(char),1,HatFileRandom); }
+          { char arity; myfread(&arity,sizeof(char),1,HatFileRandom);
             readString();
             while (n--) readFO();
             ptr = readFO();
diff --git a/tools/finitemap.c b/tools/finitemap.c
--- a/tools/finitemap.c
+++ b/tools/finitemap.c
@@ -41,8 +41,8 @@
   t->key   = key;
   t->value = value;
   t->size  = 1;
-  t->left  = (cast)NULL;
-  t->right = (cast)NULL;
+  t->left  = NULL;
+  t->right = NULL;
   return t;
 }
 
diff --git a/tools/finitemap.h b/tools/finitemap.h
--- a/tools/finitemap.h
+++ b/tools/finitemap.h
@@ -7,7 +7,7 @@
 
 /* external API */
 typedef struct _FM* FiniteMap;
-typedef void* cast;
+typedef void* cast; 
 typedef int  (*FMComparison) (cast a, cast b);
 typedef int  (*FMTraversal)  (cast key, cast value, cast dummy);
 typedef void (*FMFreeItem)   (cast key, cast value);
diff --git a/tools/hat-check.c b/tools/hat-check.c
--- a/tools/hat-check.c
+++ b/tools/hat-check.c
@@ -486,7 +486,7 @@
     sprintf(fixpribuf, " infixl %d,", b/4);
     break;
   case 3:
-    sprintf(fixpribuf, "");
+    sprintf(fixpribuf, "%s", "");
     break;
   }
   return fixpribuf;
@@ -594,7 +594,8 @@
 header (void)
 {
   char s[9];
-  fread(s,sizeof(char),8,f); s[8]='\0';
+  if (fread(s,sizeof(char),8,f) != 8) {fprintf (stderr,"No header.\n"); exit(1);}
+  s[8]='\0';
   nextoffset = 8;
   if (amode) printf("%s", s);
   if (amode) printf("\nEntry point: ");
@@ -913,7 +914,8 @@
 markfromheader (uint32_t *buf)
 {
   fseek(f,8L,SEEK_SET);
-  fread(buf,sizeof(uint32_t),2,f);
+  if (fread(buf,sizeof(uint32_t),2,f) != 2)
+    { fprintf(stderr, "markfromheader: reading 2 32ints failed.\n"); exit(1);}
   markfrom(getpointer(buf+1),buf+1);
   markfrom(getpointer(buf),  buf);
 }
@@ -944,7 +946,8 @@
      * If it is not marked, then mark it now.
      */
     fseek(f,root,SEEK_SET);
-    fread(&tag,sizeof(char),1,f);
+    if (fread(&tag,sizeof(char),1,f) != 1)
+      { fprintf(stderr, "markfrom: reading character failed.\n"); exit(1);}
     if (ismarked(tag)) return;
     marktag(&tag);
     fseek(f,root,SEEK_SET);
@@ -966,7 +969,8 @@
       }
       switch (k) {
         case ListCons:
-          fread(buf,sizeof(uint32_t),2,f);	/* two pointers */
+          if (fread(buf,sizeof(uint32_t),2,f) != 2)	/* two pointers */
+	    { fprintf(stderr, "markfrom: reading two pointers failed.\n"); exit(1);}
           markfrom(getpointer(buf+1),buf+1);
           markfrom(getpointer(buf),buf);
 	  break;
@@ -976,41 +980,51 @@
         case SrcPos:
         case AtomVariable:
         case AtomConstructor: 	/* ignore fieldnames for now */
-          fread(buf,sizeof(uint32_t),1,f);	/* points to module mode */
+          if (fread(buf,sizeof(uint32_t),1,f) != 1)	/* points to module mode */
+	    { fprintf(stderr, "markfrom: reading a pointer failed.\n"); exit(1);}
           markfrom(getpointer(buf),buf);
           break;
 
         default: {
           int pos = 0;
           if (hasSrcPos(tag)) {
-            fread(buf+pos,sizeof(uint32_t),1,f);
+            if (fread(buf+pos,sizeof(uint32_t),1,f) != 1)
+	      { fprintf(stderr, "markfrom: reading a pointer failed.\n"); exit(1);}
             pos++;
           }
-          fread(buf+pos,sizeof(uint32_t),1,f);	/* parent pointer */
+          if (fread(buf+pos,sizeof(uint32_t),1,f) != 1)	/* parent pointer */
+	    { fprintf(stderr, "markfrom: reading parent pointer failed.\n"); exit(1);}
           pos++;
           switch (k) {
             case ExpApp:
-              fread(buf+pos,sizeof(uint32_t),2,f); /* result+fun */
+              if (fread(buf+pos,sizeof(uint32_t),2,f) != 1) /* result+fun */
+		{ fprintf(stderr, "markfrom: reading result+fun failed.\n"); exit(1);}
               pos += 2;
               { unsigned char arity;
-                fread(&arity,sizeof(unsigned char),1,f);
-                fread(buf+pos,sizeof(uint32_t),(unsigned int)arity,f);
+                if (fread(&arity,sizeof(unsigned char),1,f) != 1)
+		  { fprintf(stderr, "markfrom: reading character failed.\n"); exit(1);}
+                if (fread(buf+pos,sizeof(uint32_t),(unsigned int)arity,f) != arity)
+		  { fprintf(stderr, "markfrom: reading arguments failed.\n"); exit(1);}
                 pos += (int)arity;
               }
 	      break;
             case ExpValueApp:
-              fread(buf+pos,sizeof(uint32_t),1,f); /* fun */
+              if (fread(buf+pos,sizeof(uint32_t),1,f) != 1) /* fun */
+		{ fprintf(stderr, "markfrom: reading fun failed.\n"); exit(1);}
               pos += 1;
               { unsigned char arity;
-                fread(&arity,sizeof(unsigned char),1,f);
-                fread(buf+pos,sizeof(uint32_t),(unsigned int)arity,f);
+                if (fread(&arity,sizeof(unsigned char),1,f) != 1)
+		  { fprintf(stderr, "markfrom: reading arity failed.\n"); exit(1);}
+                if (fread(buf+pos,sizeof(uint32_t),(unsigned int)arity,f) != arity)
+		  { fprintf(stderr, "markfrom: reading arguments failed.\n"); exit(1);}
                 pos += (int)arity;
               }
 	      break;
             case ExpValueUse:
             case ExpConstUse:
             case ExpProjection:
-              fread(buf+pos,sizeof(uint32_t),1,f);	/* one extra pointer */
+	      if (fread(buf+pos,sizeof(uint32_t),1,f) != 1)	/* one extra pointer */
+		{ fprintf(stderr, "markfrom: reading pointer failed.\n"); exit(1);}
               pos++;
 	      break;
             case ExpHidden:
@@ -1019,7 +1033,8 @@
             case ExpGuard:
             case ExpCase:
             case ExpIf:
-              fread(buf+pos,sizeof(uint32_t),2,f);	/* two pointers */
+	      if (fread(buf+pos,sizeof(uint32_t),2,f) != 2)	/* two pointers */
+		{ fprintf(stderr, "markfrom: reading two pointers failed.\n"); exit(1);}
               pos+=2;
 	      break;
             default: break;				/* no pointers */
diff --git a/tools/hat-names.c b/tools/hat-names.c
--- a/tools/hat-names.c
+++ b/tools/hat-names.c
@@ -72,8 +72,8 @@
 void
 map1_insert (FileOffset node, char* id, idkind k, unsigned char arity)
 {
-  item *it = (item*)0;
-  it = FM_lookup(map1,(cast)node);
+  item *it = (item*)NULL;
+  it = FM_lookup(map1,(cast)(uintptr_t)node);
   if (!it) {
     it = (item*)malloc(sizeof(item));
     it->name  = id;
@@ -83,14 +83,14 @@
     it->pending = 0;
     it->thunks  = 0;
     it->thispos = node;
-    FM_insert(map1,(cast)node,(cast)it);
+    FM_insert(map1,(cast)(uintptr_t)node,(cast)it);
   }
 }
 defn*
 map2_insert (FileOffset usage, FileOffset def, unsigned char ap)
 {
-  item *it = (item*)0;
-  it = FM_lookup(map1,(cast)def);
+  item *it = (item*)NULL;
+  it = FM_lookup(map1,(cast)(uintptr_t)def);
   if (it) {
     defn *fn;
     fn = (defn*)malloc(sizeof(defn));
@@ -99,7 +99,7 @@
     fn->next  = (defn*)0;
   //if (strcmp(it->name,">=")==0)
   //  fprintf(stderr,"map2: %s at 0x%x (%d)\n",it->name,usage,it->uses);
-    FM_insert(map2,(cast)usage,(cast)fn);
+    FM_insert(map2,(cast)(uintptr_t)usage,(cast)fn);
     return fn;
   } else return (defn*)0;
 }
@@ -333,10 +333,10 @@
           fun = q_readFO();	/* keep fun ptr */
           q_fread(&size,sizeof(unsigned char),1,HatFileSeq);	/* get arity */
           for (i=0; i<size; i++) q_readFO();	/* skip args */
-          def = (defn*)FM_lookup(map2,(cast)fun);
+          def = (defn*)FM_lookup(map2,(cast)(uintptr_t)fun);
           if (def) {
             defn *def2;
-            it = FM_lookup(map1,(cast)def->atom);
+            it = FM_lookup(map1,(cast)(uintptr_t)def->atom);
             if (it) {
               if (size>=def->arity) {
                 if (result==Entered) it->pending += 1;
@@ -348,7 +348,7 @@
               fprintf(stderr,"unknown atom in fun at (ExpApp 0x%x)\n",node);
             }
             if (def->next) {
-              it = FM_lookup(map1,(cast)def->next->atom);
+              it = FM_lookup(map1,(cast)(uintptr_t)def->next->atom);
               if (it) {
                 if (size>=def->next->arity) {
                   if (result==Entered) it->pending += 1;
@@ -376,7 +376,7 @@
           fun = q_readFO();	/* fun ptr is an Atom ref */
           q_fread(&size,sizeof(unsigned char),1,HatFileSeq);	/* get arity */
           for (i=0; i<size; i++) q_readFO();	/* skip args */
-          it = FM_lookup(map1,(cast)fun);
+          it = FM_lookup(map1,(cast)(uintptr_t)fun);
           if (it) {
             if (size>=it->arity) {
               it->uses += 1;
@@ -395,7 +395,7 @@
         { FileOffset atom; item *it;
           atom = q_readFO();	/* get atom */
           if ((atom!=Lambda)&&(atom!=DoLambda)) {
-            it = FM_lookup(map1,(cast)atom);
+            it = FM_lookup(map1,(cast)(uintptr_t)atom);
             if (it) {
               map2_insert(node,atom,0);
               if ((it->kind==Construct) && (it->arity==0)) it->uses+=1;
@@ -407,11 +407,11 @@
         q_readFO();		/* skip parent */
         { FileOffset exp; defn *def; item *it;
           exp = q_readFO();	/* get ExpConstDef location */
-          def = FM_lookup(map2,(cast)exp);
+          def = FM_lookup(map2,(cast)(uintptr_t)exp);
           if (def) {
             defn *def2;
             def2 = map2_insert(node,def->atom,0);
-            it = FM_lookup(map1,(cast)def->atom);
+            it = FM_lookup(map1,(cast)(uintptr_t)def->atom);
             if (it) it->uses+=1;
             else fprintf(stderr
                         ,"unknown atom in defn in (ExpConstUse 0x%x)\n",node);
@@ -425,7 +425,7 @@
           q_readFO();		/* skip parent */
           result = q_readFO();	/* result might be significant */
           atom = q_readFO();	/* get atom */
-          it = FM_lookup(map1,(cast)atom);
+          it = FM_lookup(map1,(cast)(uintptr_t)atom);
           if (it) def = map2_insert(node,atom,0);
           else fprintf(stderr,"unknown atom in (ExpConstDef 0x%x)\n",node);
           countCAFResult(node,result,def,0,0);
@@ -489,9 +489,9 @@
           fun = readFO();
           fread(&size,sizeof(unsigned char),1,HatFileRandom);   /* arity */
           if (fun < caf) {      /* fun already seen in linear scan */
-            atom = (defn*)FM_lookup(map2,(cast)fun);
+            atom = (defn*)FM_lookup(map2,(cast)(uintptr_t)fun);
             if (atom) {
-              it = (item*)FM_lookup(map1,(cast)atom->atom);
+              it = (item*)FM_lookup(map1,(cast)(uintptr_t)atom->atom);
               if (it) {
                 defn *def2;
                 def2 = (defn*)malloc(sizeof(defn));
@@ -515,7 +515,7 @@
           if ((var==Lambda)||(var==DoLambda)) return;
           if (var < caf) {
             HIDE(fprintf(stderr,"countCAF: var=0x%x < caf=0x%x\n",var,caf);)
-            it = (item*)FM_lookup(map1,(cast)var);
+            it = (item*)FM_lookup(map1,(cast)(uintptr_t)var);
             HIDE(if (it) fprintf(stderr,"countCAF: var=%s\n",it->name);)
             if (it && (arity<it->arity)) {
               defn *def2;
diff --git a/tools/observeutils.c b/tools/observeutils.c
--- a/tools/observeutils.c
+++ b/tools/observeutils.c
@@ -36,7 +36,7 @@
   info->node  = atom;
   info->var   = var;
   info->arity = arity;
-  FM_insert(mapAtom2Info,(cast)atom,(cast)info);
+  FM_insert(mapAtom2Info,(cast)(uintptr_t)atom,(cast)info);
 }
 /* Insert into either mapExp2Atom or mapContext2Atom */
 void
@@ -44,13 +44,13 @@
             ,unsigned char arity)
 {
   Info *info = (Info*)0;
-  info = FM_lookup(mapAtom2Info,(cast)atom);
+  info = FM_lookup(mapAtom2Info,(cast)(uintptr_t)atom);
   if (info) {
     Atom *fun;
     fun = (Atom*)malloc(sizeof(Atom));
     fun->atom  = atom;
     fun->arity = info->arity - arity;
-    FM_insert(map2,(cast)exp,(cast)fun);
+    FM_insert(map2,(cast)(uintptr_t)exp,(cast)fun);
   }
 }
 /* free memory when no longer needed */
@@ -187,9 +187,9 @@
           for (i=0; i<size; i++) q_readFO();    /* skip args */
           /* First check if this is a possible caller context */
           if (o_context) {
-            atom = (Atom*)FM_lookup(mapContext2Atom,(cast)fun);
+            atom = (Atom*)FM_lookup(mapContext2Atom,(cast)(uintptr_t)fun);
             if (atom) {
-              it = (Info*)FM_lookup(mapAtom2Info,(cast)atom->atom);
+              it = (Info*)FM_lookup(mapAtom2Info,(cast)(uintptr_t)atom->atom);
               if (it && !strcmp(it->var,o_caller)) {
                 insert_map2(mapContext2Atom,node,atom->atom,size);
                 HIDE(fprintf(stderr,"App of %s (context) ",it->var);)
@@ -197,24 +197,24 @@
             }
           }
           /* Then check if we have found the right callee */
-          atom = (Atom*)FM_lookup(mapExp2Atom,(cast)fun);
+          atom = (Atom*)FM_lookup(mapExp2Atom,(cast)(uintptr_t)fun);
           if (atom) {
-            it = (Info*)FM_lookup(mapAtom2Info,(cast)atom->atom);
+            it = (Info*)FM_lookup(mapAtom2Info,(cast)(uintptr_t)atom->atom);
             if (it && !strcmp(it->var,o_callee)) {
               HIDE(fprintf(stderr,"App of %s (callee)",it->var);)
               if (size >= atom->arity) {  /* is not undersaturated */
                 if (!o_recursive) {  /* if excluding recursive calls */
                   insert_map2(mapContext2Atom,node,atom->atom,size);
-                  atom = (Atom*)FM_lookup(mapContext2Atom,(cast)parent);
+                  atom = (Atom*)FM_lookup(mapContext2Atom,(cast)(uintptr_t)parent);
                   if (atom) {
-                    it =(Info*)FM_lookup(mapAtom2Info,(cast)atom->atom);
+                    it =(Info*)FM_lookup(mapAtom2Info,(cast)(uintptr_t)atom->atom);
                     if (it && !strcmp(it->var,o_callee)) return 0;
                     else return node;
                   } else return node;
                 } else if (o_context) {	 /* if context matters */
-                  atom = (Atom*)FM_lookup(mapContext2Atom,(cast)parent);
+                  atom = (Atom*)FM_lookup(mapContext2Atom,(cast)(uintptr_t)parent);
                   if (atom) {
-                    it =(Info*)FM_lookup(mapAtom2Info,(cast)atom->atom);
+                    it =(Info*)FM_lookup(mapAtom2Info,(cast)(uintptr_t)atom->atom);
                     HIDE(fprintf(stderr,"(context is %s)",it->var);)
                     if (it && !strcmp(it->var,o_caller)) return node;
                   }
@@ -231,13 +231,13 @@
           fun = q_readFO();     /* fun ptr is an Atom ref */
           q_fread(&size,sizeof(unsigned char),1,HatFileSeq);    /* get arity */
           for (i=0; i<size; i++) q_readFO();    /* skip args */
-          it = (Info*)FM_lookup(mapAtom2Info,(cast)fun);
+          it = (Info*)FM_lookup(mapAtom2Info,(cast)(uintptr_t)fun);
           if (it && !strcmp(it->var,o_callee)) {
             if (size >= it->arity) {
               if (o_context) {	/* if context matters */
-                atom = (Atom*)FM_lookup(mapContext2Atom,(cast)parent);
+                atom = (Atom*)FM_lookup(mapContext2Atom,(cast)(uintptr_t)parent);
                 if (atom) {
-                  it =(Info*)FM_lookup(mapAtom2Info,(cast)atom->atom);
+                  it =(Info*)FM_lookup(mapAtom2Info,(cast)(uintptr_t)atom->atom);
                   HIDE(fprintf(stderr,"(context is %s)",it->var);)
                   if (it && !strcmp(it->var,o_caller)) return node;
                 }
@@ -272,9 +272,9 @@
           if ((atom==Lambda)||(atom==DoLambda)) {
             if (o_context || !o_recursive) {
               Atom *atom;	/* shadows outer scope */
-              atom = (Atom*)FM_lookup(mapContext2Atom,(cast)parent);
+              atom = (Atom*)FM_lookup(mapContext2Atom,(cast)(uintptr_t)parent);
               if (atom) {
-                it = (Info*)FM_lookup(mapAtom2Info,(cast)atom->atom);
+                it = (Info*)FM_lookup(mapAtom2Info,(cast)(uintptr_t)atom->atom);
                 if (it) {
                   if ( (!o_recursive && !strcmp(it->var,o_callee))
                      || (o_context && !strcmp(it->var,o_caller)) ) {
@@ -284,7 +284,7 @@
               }
             }
           } else {
-            it = (Info*)FM_lookup(mapAtom2Info,(cast)atom);
+            it = (Info*)FM_lookup(mapAtom2Info,(cast)(uintptr_t)atom);
             if (it) {
               if (!strcmp(it->var,o_callee)) {
                 insert_map2(mapExp2Atom,node,atom,0);
@@ -303,7 +303,7 @@
           q_readFO();		/* skip parent */
           result = q_readFO();	/* result might contain desired function */
           atom = q_readFO();	/* get atom */
-          it = (Info*)FM_lookup(mapAtom2Info,(cast)atom);
+          it = (Info*)FM_lookup(mapAtom2Info,(cast)(uintptr_t)atom);
           if (it) {
             HIDE(fprintf(stderr,"ConstDef %s",it->var);)
             if (!strcmp(it->var,o_callee))
@@ -322,16 +322,16 @@
         { FileOffset exp; Atom *def; Info *it;
           q_readFO();		/* skip parent */
           exp = q_readFO();	/* get ExpConstDef location */
-          def = (Atom*)FM_lookup(mapExp2Atom,(cast)exp);
+          def = (Atom*)FM_lookup(mapExp2Atom,(cast)(uintptr_t)exp);
           if (def) {
             insert_map2(mapExp2Atom,node,def->atom,def->arity);	// allows oversat apps
-            it = FM_lookup(mapAtom2Info,(cast)def->atom);
+            it = FM_lookup(mapAtom2Info,(cast)(uintptr_t)def->atom);
             HIDE(if (it) fprintf(stderr,"%s",it->var);)
             if (it && !strcmp(it->var,o_callee)) return node;
           } else {
-            def = (Atom*)FM_lookup(mapContext2Atom,(cast)exp);
+            def = (Atom*)FM_lookup(mapContext2Atom,(cast)(uintptr_t)exp);
             if (def) {
-              it = FM_lookup(mapAtom2Info,(cast)def->atom);
+              it = FM_lookup(mapAtom2Info,(cast)(uintptr_t)def->atom);
               if (it && !strcmp(it->var,o_caller))
                 insert_map2(mapContext2Atom,node,def->atom,def->arity);
             }
@@ -346,9 +346,9 @@
             parent = q_readFO();
             q_readFO();	/* skip result */
             q_readFO();	/* skip condition */
-            atom = (Atom*)FM_lookup(mapContext2Atom,(cast)parent);
+            atom = (Atom*)FM_lookup(mapContext2Atom,(cast)(uintptr_t)parent);
             if (atom) {
-              it = (Info*)FM_lookup(mapAtom2Info,(cast)atom->atom);
+              it = (Info*)FM_lookup(mapAtom2Info,(cast)(uintptr_t)atom->atom);
               if (it) {
                 if ( (!o_recursive && !strcmp(it->var,o_callee))
                    || (o_context && !strcmp(it->var,o_caller)) ) {
@@ -469,17 +469,17 @@
           fread(&size,sizeof(unsigned char),1,HatFileRandom);	/* arity */
           if (fun < caf) {	/* fun already seen in linear scan */
             if (o_context) {
-              atom = (Atom*)FM_lookup(mapContext2Atom,(cast)fun);
+              atom = (Atom*)FM_lookup(mapContext2Atom,(cast)(uintptr_t)fun);
               if (atom) {
-                it = (Info*)FM_lookup(mapAtom2Info,(cast)atom->atom);
+                it = (Info*)FM_lookup(mapAtom2Info,(cast)(uintptr_t)atom->atom);
                 if (it && !strcmp(it->var,o_caller)) {
                   insert_map2(mapContext2Atom,caf,atom->atom,size);
                 }
               }
             }
-            atom = (Atom*)FM_lookup(mapExp2Atom,(cast)fun);
+            atom = (Atom*)FM_lookup(mapExp2Atom,(cast)(uintptr_t)fun);
             if (atom) {
-              it = (Info*)FM_lookup(mapAtom2Info,(cast)atom->atom);
+              it = (Info*)FM_lookup(mapAtom2Info,(cast)(uintptr_t)atom->atom);
               if (it && !strcmp(it->var,o_callee)
                      && ((size+arity)<atom->arity)) {
                 HIDE(fprintf(stderr,"searchCAF: STORING caf=0x%x var=%s, size=%d\n",caf,it->var,size);)
@@ -502,7 +502,7 @@
           if (var==DoLambda) return;
           if (var < caf) {
             HIDE(fprintf(stderr,"searchCAF: var=0x%x < caf=0x%x\n",var,caf);)
-            it = (Info*)FM_lookup(mapAtom2Info,(cast)var);
+            it = (Info*)FM_lookup(mapAtom2Info,(cast)(uintptr_t)var);
             HIDE(if (it) fprintf(stderr,"searchCAF: var=%s\n",it->var);)
             if (it && !strcmp(it->var,o_callee) && (arity<it->arity)) {
               HIDE(fprintf(stderr,"searchCAF: STORING caf=0x%x var=%s, size=%d\n",caf,it->var,arity);)
