diff --git a/.gitignore b/.gitignore
index a3ef9816d5f5b9f468d6846a16b581923529ea18..2935b57c072486dc4139c46cae576e43c33cc71a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,12 +3,15 @@
 *.src
 *.temp
 bin/*
-log/src/simdir.c
-log/munch.temp
-log/src/tooldir.c
-log/src/ana/logdef.h
-log/src/log
-log/src/loged
-log/target/
+src/simdir.c
+munch.temp
+src/tooldir.c
+src/ana/logdef.h
+src/log
+src/loged
+target/
 /.vscode
 /.idea
+lib/texstuff.ps
+lib/untilstuff.ps
+build/
diff --git a/log/LNOTES b/LNOTES
similarity index 100%
rename from log/LNOTES
rename to LNOTES
diff --git a/Makefile b/Makefile
index f40adfb8a65063ae426ebe6e3e0c044132488827..c42fa7105b433d37b0db906c1e87e65bb8e969a9 100644
--- a/Makefile
+++ b/Makefile
@@ -1,14 +1,166 @@
-# ARCH_OPT is the gcc architecture option (probably -m32 or -m64)
-export ARCH_OPT="-m32"
-MAKE="make"
 
-all: clean build
+#  "LOG", the circuit editing and simulation system, 5.66
+#  "DigLOG", the digital simulator for LOG.
+#  Copyright (C) 1985, 1990 David Gillespie.
+#  Author's address: daveg@synaptics.edu
 
-build:
-	$(MAKE) -C psys/src
-	$(MAKE) -C log
+#  "AnaLOG", the analog simulator for LOG, 5.66
+#  Copyright (C) 1985, 1990 John Lazzaro.
+#  Author's address: lazzaro@cs.berkeley.edu;
 
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation (any version).
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; see the file COPYING.  If not, write to
+# the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ARCH_OPT = -m32
+
+CD = cd
+
+LOGINC = include
+TARGET_DIR = target
+SRC_DIR = src
+TOOLS_DIR = tools
+
+LOGLIBDIR = `$(CD) lib; pwd`
+LIBDIR = `$(CD) lib; pwd`
+
+XINCLUDEDIR = .
+
+BINDIR = bin
+
+LIBX11 = -lX11
+
+OTHERLIBS= -lm
+
+CHIPMUNKCC = gcc -O2
+
+CC = $(CHIPMUNKCC)
+
+CHIPMUNKFLAGS = $(ARCH_OPT)
+
+STDC = gnu11
+
+CFLAGS = $(CHIPMUNKFLAGS) -I$(LOGINC) -I$(XINCLUDEDIR)	\
+	 -DLOGLIB="\"$(LOGLIBDIR)\"" -DF_OK=0 -std=$(STDC) -DCHIPLIB=$(LIBDIR) -g -Wall -Wextra
+
+## (3) Choosing default fonts
+## --------------------------
+##
+## By default, Chipmunk expects the Xserver to have
+## the 6x10 and 8x13 fonts available. This default
+## may be overriden via .Xresources. To change the
+## the default fonts, define FONTS as with the syntax:
+##
+## FONTS = -DNEWCRT_FONT=\"8x13\" -DMYLIB_FONT=\"6x10\"
+##
+## and change the double-quoted fonts to reflect the
+## fonts available for your system. For example, try:
+##
+## FONTS = -DNEWCRT_FONT=\"7x13\" -DMYLIB_FONT=\"6x12\"
+##
+
+FONTS =
+
+GRAPHICSOBJ = $(TARGET_DIR)/graphics/newci.o \
+			$(TARGET_DIR)/graphics/newkbd.o \
+			$(TARGET_DIR)/graphics/newcrt.o \
+			$(TARGET_DIR)/graphics/mylib.o
+
+UTILSOBJ = $(TARGET_DIR)/utils/sysdevs.o \
+		$(TARGET_DIR)/utils/misc.o \
+		$(TARGET_DIR)/utils/filepack.o \
+		$(TARGET_DIR)/utils/iodecl.o \
+		$(TARGET_DIR)/utils/strings.o \
+		$(TARGET_DIR)/utils/strlist.o \
+		$(TARGET_DIR)/utils/newasm.o \
+		$(TARGET_DIR)/utils/regex.o \
+		$(TARGET_DIR)/utils/p2c.o \
+
+P2CLIBSTUFF = $(SRC_DIR)/lib/texstuff.ps $(SRC_DIR)/lib/untilstuff.ps $(SRC_DIR)/lib/plot.font
+
+DIGOBJ = $(TARGET_DIR)/logsim.o $(TARGET_DIR)/logdig.o		\
+         $(TARGET_DIR)/logsimasm.o $(TARGET_DIR)/logsimed.o	\
+         $(TARGET_DIR)/diggates.o $(TARGET_DIR)/loghier.o	\
+         $(TARGET_DIR)/logsimh.o $(TARGET_DIR)/swap.o
+ANAOBJ = $(TARGET_DIR)/ana/globals.o $(TARGET_DIR)/ana/nsolver.o	\
+         $(TARGET_DIR)/ana/main.o $(TARGET_DIR)/ana/inter.o		\
+         $(TARGET_DIR)/ana/numbers.o $(TARGET_DIR)/ana/mmeter.o		\
+         $(TARGET_DIR)/ana/iscope.o $(TARGET_DIR)/ana/devtechp.o	\
+         $(TARGET_DIR)/ana/vdiff.o $(TARGET_DIR)/ana/vswitch.o		\
+         $(TARGET_DIR)/ana/stairs.o $(TARGET_DIR)/ana/runspec.o		\
+         $(TARGET_DIR)/ana/idiff.o $(TARGET_DIR)/ana/iswitch1.o		\
+         $(TARGET_DIR)/ana/iswitch2.o $(TARGET_DIR)/ana/devtechn.o	\
+         $(TARGET_DIR)/ana/resfloat.o $(TARGET_DIR)/ana/capfloat.o	\
+         $(TARGET_DIR)/ana/nfet4.o $(TARGET_DIR)/ana/pfet4.o		\
+         $(TARGET_DIR)/ana/nfet5.o $(TARGET_DIR)/ana/pfet5.o		\
+         $(TARGET_DIR)/ana/pfet6.o $(TARGET_DIR)/ana/pspc1.o		\
+         $(TARGET_DIR)/ana/nspc1.o $(TARGET_DIR)/ana/nfet7t.o		\
+         $(TARGET_DIR)/ana/nfet7f.o $(TARGET_DIR)/ana/pfet7t.o		\
+         $(TARGET_DIR)/ana/pfet7f.o $(TARGET_DIR)/ana/thermal.o		\
+         $(TARGET_DIR)/ana/tc.o $(TARGET_DIR)/ana/moscap.o		\
+         $(TARGET_DIR)/ana/ganglion.o $(TARGET_DIR)/ana/hres.o		\
+         $(TARGET_DIR)/ana/physical.o $(TARGET_DIR)/ana/npn1.o		\
+         $(TARGET_DIR)/ana/pnp1.o $(TARGET_DIR)/ana/npn2.o		\
+         $(TARGET_DIR)/ana/pnp2.o $(TARGET_DIR)/ana/diode1.o		\
+         $(TARGET_DIR)/ana/pwl.o $(TARGET_DIR)/ana/rtd.o
+
+SIMOBJ = $(TARGET_DIR)/logcom.o $(DIGOBJ) $(ANAOBJ)
+TOOLOBJ = $(SIMOBJ) $(TARGET_DIR)/logspc.o $(TARGET_DIR)/logntk.o	\
+	  $(TARGET_DIR)/label.o $(TARGET_DIR)/wire.o			\
+	  $(TARGET_DIR)/page.o $(TARGET_DIR)/gate.o			\
+	  $(TARGET_DIR)/screen.o $(TARGET_DIR)/node.o			\
+	  $(TARGET_DIR)/tool.o $(TARGET_DIR)/utils.o		\
+	  $(TARGET_DIR)/pagewriter.o $(TARGET_DIR)/pagereader.o
+
+
+$(TARGET_DIR)/ana/%.o: $(SRC_DIR)/ana/%.c
+$(TARGET_DIR)/graphics/%.o: $(SRC_DIR)/graphics/%.c
+$(TARGET_DIR)/utils/%.o: $(SRC_DIR)/utils/%.c
+$(TARGET_DIR)/%.o: $(SRC_DIR)/%.c
+	@mkdir -p $(@D)
+	$(CC) -c $(CFLAGS) $< -o $@
+
+install: all
+	cp $(P2CLIBSTUFF) $(LIBDIR)
+	cp $(TARGET_DIR)/log $(BINDIR)/diglog
+	-rm -f $(BINDIR)/analog
+	-(cd $(BINDIR); ln -s diglog analog)
+	cp $(TARGET_DIR)/loged $(BINDIR)/loged
 
 clean:
-	$(MAKE) -C psys/src clean
-	$(MAKE) -C log clean
+	rm -rf $(TARGET_DIR)/*
+
+all: setup clean main
+
+setup:
+	-if [ ! -d $(LIBDIR) ] ; then mkdir $(LIBDIR) ; fi
+
+main: $(TARGET_DIR)/log $(TARGET_DIR)/loged
+
+LOGOBJ = $(TARGET_DIR)/log.o $(TOOLOBJ) $(TARGET_DIR)/tooldir.o $(TARGET_DIR)/logdef.o $(TARGET_DIR)/logstuff.o
+LOGEDOBJ = $(TARGET_DIR)/loged.o $(TARGET_DIR)/simdir.o $(SIMOBJ) $(TARGET_DIR)/logstuff.o
+
+$(SRC_DIR)/tooldir.c: $(TOOLOBJ)
+	chmod +x $(TOOLS_DIR)/munch
+	$(TOOLS_DIR)/munch 'Log_[a-zA-Z0-9_]*' $^ > $@
+
+$(SRC_DIR)/simdir.c: $(SIMOBJ)
+	chmod +x $(TOOLS_DIR)/munch
+	$(TOOLS_DIR)/munch 'Log_[0-9]*_proc' $^ > $@
+
+$(TARGET_DIR)/log: $(LOGOBJ) $(GRAPHICSOBJ) $(UTILSOBJ)
+	$(CC) $(CFLAGS) $^ $(LIBX11) $(OTHERLIBS) -o $@
+
+$(TARGET_DIR)/loged: $(LOGEDOBJ) $(GRAPHICSOBJ) $(UTILSOBJ)
+	$(CC) $(CFLAGS) $^ $(LIBX11) $(OTHERLIBS) -o $@
+
+.PHONY: all install main clean setup
diff --git a/README.md b/README.md
index eaf706c7b0bab82519dc277af5faaaa6752cc4df..0587fcacd4aaeaa6b8d27fb21ab00136a56d7b9a 100644
--- a/README.md
+++ b/README.md
@@ -4,15 +4,16 @@
 
 **IMPORTANT: We are not going to maintain this version of the code. The new project is under https://git.iiens.net/diglog**
 
-Log (diglog + analog) is a graphical environment for entering circuit schematics, and for analog 
-and digital circuit simulation. Please see [log/README](log/README) for more information.
+Log (diglog + analog) is a graphical environment for entering circuit
+schematics, and for analog and digital circuit simulation. Please see
+[previous README](README.old) for more information.
 
 This is a fork of a part of the [Chipmunk
 Distribution](https://john-lazzaro.github.io/chipmunk/pickup/pickup.html)
-last maintained by [John Lazzaro](https://github.com/john-lazzaro).
+maintained by [John Lazzaro](https://github.com/john-lazzaro).
 
-This repo has for goal to get rid of old code and make the rest
-compliant with modern practices, protocols, frameworks and operating systems/architectures.
+This repo has for goal to get rid of old code and make the rest compliant with
+modern practices, protocols, frameworks and operating systems/architectures.
 
 Later on, we might add new features.
 
@@ -81,4 +82,4 @@ _Not yet implemented_
 
     You should have received a copy of the GNU General Public License
     along with this program.  If not, see <http://www.gnu.org/licenses/>.
-```
\ No newline at end of file
+```
diff --git a/log/README b/README.old
similarity index 100%
rename from log/README
rename to README.old
diff --git a/log/include/ana/capfloat.h b/include/ana/capfloat.h
similarity index 63%
rename from log/include/ana/capfloat.h
rename to include/ana/capfloat.h
index 888e8446b81737deb0d3f613fdda256929106442..9e1ffe8ca7c9df393753d218672cbceb3584b372 100644
--- a/log/include/ana/capfloat.h
+++ b/include/ana/capfloat.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 void Log_capfloat_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/devtechn.h b/include/ana/devtechn.h
similarity index 64%
rename from log/include/ana/devtechn.h
rename to include/ana/devtechn.h
index f88c712b9f0d86286ea2388c14082900b4ffd08f..ccc832826de87fa11b7087bcc59a4819b5e0a974 100644
--- a/log/include/ana/devtechn.h
+++ b/include/ana/devtechn.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_DEVTECHN_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/devtechp.h b/include/ana/devtechp.h
similarity index 64%
rename from log/include/ana/devtechp.h
rename to include/ana/devtechp.h
index 46acff08340d8fe10f66ae9bae09a91738693208..03a14bbff85249aaf2d9732e5b6845df1c798fff 100644
--- a/log/include/ana/devtechp.h
+++ b/include/ana/devtechp.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_DEVTECHP_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/diode1.h b/include/ana/diode1.h
similarity index 60%
rename from log/include/ana/diode1.h
rename to include/ana/diode1.h
index 23fde96b7e4f2ba58e295132c5b7dd8e5c91448f..13aa613267d116b4ca683f8f109412a8d51dcb4a 100644
--- a/log/include/ana/diode1.h
+++ b/include/ana/diode1.h
@@ -3,10 +3,10 @@
 
 #include "logdef.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_Diode1_INITLIB_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/ganglion.h b/include/ana/ganglion.h
similarity index 64%
rename from log/include/ana/ganglion.h
rename to include/ana/ganglion.h
index 32ed5f44b20062fefbfec62f8b8e57e531b27d0f..a93407f85ccf111ce4cd0cb9552d5713f9599478 100644
--- a/log/include/ana/ganglion.h
+++ b/include/ana/ganglion.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_ganglion_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/globals.h b/include/ana/globals.h
similarity index 99%
rename from log/include/ana/globals.h
rename to include/ana/globals.h
index 1bcd4e4a78a81fe75efe8539e70db53e7c2096a2..6f750e2800b61ccefad55c4cf0af6e1c9411ad80 100644
--- a/log/include/ana/globals.h
+++ b/include/ana/globals.h
@@ -4,9 +4,9 @@
 
 
 #include "logdef.h"
-#include <p2c/newci.h>
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
+#include <graphics/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
 
 #ifdef GLOBALS_G
 # define vextern
diff --git a/log/include/ana/hres.h b/include/ana/hres.h
similarity index 62%
rename from log/include/ana/hres.h
rename to include/ana/hres.h
index 1e2c45afaabdfcdfec90aaa4822bf84a34cb0edf..422bd0eb8acd699c46e6c448c05a31663de02062 100644
--- a/log/include/ana/hres.h
+++ b/include/ana/hres.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_hres_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/idiff.h b/include/ana/idiff.h
similarity index 63%
rename from log/include/ana/idiff.h
rename to include/ana/idiff.h
index 1d896d1093f2255e7e48c90a737b48b89c91d2dc..33f3da8f971c0f177881c8f91201b6b42a69a0d1 100644
--- a/log/include/ana/idiff.h
+++ b/include/ana/idiff.h
@@ -5,10 +5,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_idiff_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/inter.h b/include/ana/inter.h
similarity index 67%
rename from log/include/ana/inter.h
rename to include/ana/inter.h
index 931ebad187b3ab2c6f90c4574479a590a04a2853..7d4a696218be570781471ac276d71418138c96dd 100644
--- a/log/include/ana/inter.h
+++ b/include/ana/inter.h
@@ -4,14 +4,14 @@
 
 
 #include "logdef.h"
-#include <p2c/newkbd.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newasm.h>
-#include <p2c/mylib.h>
+#include <graphics/newkbd.h>
+#include <utils/sysglobals.h>
+#include <utils/newasm.h>
+#include <graphics/mylib.h>
 #include "main.h"
 #include "ana/globals.h"
 #include "ana/nsolver.h"
-#include <p2c/newci.h>
+#include <graphics/newci.h>
 
 extern void Log_32_proc (log_action_t *act);
 extern void Log_33_proc (log_action_t *act);
diff --git a/log/include/ana/iscope.h b/include/ana/iscope.h
similarity index 63%
rename from log/include/ana/iscope.h
rename to include/ana/iscope.h
index bf10c1b2d8bee9191f7f3f09f29781fe5c0a1ac2..6fc0570b21bbaf70d2f2e45892712680c43312e8 100644
--- a/log/include/ana/iscope.h
+++ b/include/ana/iscope.h
@@ -5,10 +5,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_iscope_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/iswitch1.h b/include/ana/iswitch1.h
similarity index 69%
rename from log/include/ana/iswitch1.h
rename to include/ana/iswitch1.h
index 6a6c631bd1a866951b2f913695c4c4bd7ae2a133..15c881715374e8fdca2a6c7c3a9f3996b268b749 100644
--- a/log/include/ana/iswitch1.h
+++ b/include/ana/iswitch1.h
@@ -6,10 +6,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_iswitch1_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/iswitch2.h b/include/ana/iswitch2.h
similarity index 64%
rename from log/include/ana/iswitch2.h
rename to include/ana/iswitch2.h
index f1743f18f71f1b01e5ab3b0ae43d85eb8b7e7af3..215259547d98a15fca3c68fe1cda8a4ff04a85af 100644
--- a/log/include/ana/iswitch2.h
+++ b/include/ana/iswitch2.h
@@ -5,10 +5,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_iswitch2_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/main.h b/include/ana/main.h
similarity index 84%
rename from log/include/ana/main.h
rename to include/ana/main.h
index 0245e040ed8f5e2a8bd32dd19aeb94034314c9ba..9e25f18f289b5fac90d118c1d6cb0eb4baa347af 100644
--- a/log/include/ana/main.h
+++ b/include/ana/main.h
@@ -2,12 +2,12 @@
 #ifndef MAIN_H
 #define MAIN_H
 
-#include <p2c/newci.h>
-#include <p2c/newcrt.h>
+#include <graphics/newci.h>
+#include <graphics/newcrt.h>
 #include "ana/globals.h"
 #include "logdef.h"
-#include <p2c/newasm.h>
-#include <p2c/mylib.h>
+#include <utils/newasm.h>
+#include <graphics/mylib.h>
 
 
 extern void Analog_Cleanup ();
diff --git a/log/include/ana/mmeter.h b/include/ana/mmeter.h
similarity index 68%
rename from log/include/ana/mmeter.h
rename to include/ana/mmeter.h
index 375e32da715a03d6ff7c597c814c8bc3fec34631..0a880e273bce875d119063c78a70883e0c47b241 100644
--- a/log/include/ana/mmeter.h
+++ b/include/ana/mmeter.h
@@ -6,10 +6,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_mmeter_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/moscap.h b/include/ana/moscap.h
similarity index 63%
rename from log/include/ana/moscap.h
rename to include/ana/moscap.h
index 0f181c7f1aec5cd8b153a8010b9f08f4977e1d41..280a5cd02ce1c64ff12766248fd5e3e6576165a4 100644
--- a/log/include/ana/moscap.h
+++ b/include/ana/moscap.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_moscap_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/nfet4.h b/include/ana/nfet4.h
similarity index 63%
rename from log/include/ana/nfet4.h
rename to include/ana/nfet4.h
index c2d4a003fb3ccc1d078fc60f85321efd993f2390..5f58cc68e275a9276386946ac8385072928f3cb2 100644
--- a/log/include/ana/nfet4.h
+++ b/include/ana/nfet4.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_nfet4_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/nfet5.h b/include/ana/nfet5.h
similarity index 63%
rename from log/include/ana/nfet5.h
rename to include/ana/nfet5.h
index 76df5e219cc8316d2da1c7d86ab6a9cddc876655..4a44e136f11b4d361745e8e99717757bfbb8cb2a 100644
--- a/log/include/ana/nfet5.h
+++ b/include/ana/nfet5.h
@@ -5,10 +5,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_NFET5_INITLIB_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/nfet7f.h b/include/ana/nfet7f.h
similarity index 63%
rename from log/include/ana/nfet7f.h
rename to include/ana/nfet7f.h
index 6c38f2608acf553c95f28e917f85231eab9d8a4e..a379fc9466ec99f7ffe992513200bfd4056c270d 100644
--- a/log/include/ana/nfet7f.h
+++ b/include/ana/nfet7f.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_NFET7F_INITLIB_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/nfet7t.h b/include/ana/nfet7t.h
similarity index 63%
rename from log/include/ana/nfet7t.h
rename to include/ana/nfet7t.h
index 3db922437a964f2ee7137d60108b3b2250b0c014..475cf3b81ecfda28df1059fc1ee344ceabd86806 100644
--- a/log/include/ana/nfet7t.h
+++ b/include/ana/nfet7t.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_NFET7T_INITLIB_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/npn1.h b/include/ana/npn1.h
similarity index 62%
rename from log/include/ana/npn1.h
rename to include/ana/npn1.h
index b4ef4bbe64aca6aaee715e9df6c3f443bc7cb435..4ffb868013e7fe2ba774c5be85dd537d7c44f4b8 100644
--- a/log/include/ana/npn1.h
+++ b/include/ana/npn1.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_NPN1_INITLIB_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/npn2.h b/include/ana/npn2.h
similarity index 62%
rename from log/include/ana/npn2.h
rename to include/ana/npn2.h
index c8a8b2579e44a03d2bdbc747d18e8e1c80eeecf9..dbffbdd7fb8c7535dacca56d053cc7329ee52896 100644
--- a/log/include/ana/npn2.h
+++ b/include/ana/npn2.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_NPN2_INITLIB_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/nsolver.h b/include/ana/nsolver.h
similarity index 100%
rename from log/include/ana/nsolver.h
rename to include/ana/nsolver.h
diff --git a/log/include/ana/nspc1.h b/include/ana/nspc1.h
similarity index 63%
rename from log/include/ana/nspc1.h
rename to include/ana/nspc1.h
index 21a46b3e4e32ee31581790d1b01e0d85705d0686..18626e5eb03fffa1b7ebb5f35fcd71851dd1a488 100644
--- a/log/include/ana/nspc1.h
+++ b/include/ana/nspc1.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_NSPC1_INITLIB_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/numbers.h b/include/ana/numbers.h
similarity index 64%
rename from log/include/ana/numbers.h
rename to include/ana/numbers.h
index 6a77a6af0c16733409a58ed435d95401b7d90d7d..37a9237c1171d36839568e3252a96e6ed350e18d 100644
--- a/log/include/ana/numbers.h
+++ b/include/ana/numbers.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 
 extern void Log_numbers_initlib_32 (Analog_32_action *act);
diff --git a/log/include/ana/pfet4.h b/include/ana/pfet4.h
similarity index 63%
rename from log/include/ana/pfet4.h
rename to include/ana/pfet4.h
index b169b9d872c027b81dc51252f77793e678faa207..39105ddf3d0d04dec54d5b49d79b77d692126edf 100644
--- a/log/include/ana/pfet4.h
+++ b/include/ana/pfet4.h
@@ -5,10 +5,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_pfet4_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/pfet5.h b/include/ana/pfet5.h
similarity index 63%
rename from log/include/ana/pfet5.h
rename to include/ana/pfet5.h
index d500e06aa71b633075f9018942e866ffb6b6c53d..11f05bb00cc3b9183e030d6780316f863b3e07de 100644
--- a/log/include/ana/pfet5.h
+++ b/include/ana/pfet5.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_PFET5_INITLIB_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/pfet6.h b/include/ana/pfet6.h
similarity index 63%
rename from log/include/ana/pfet6.h
rename to include/ana/pfet6.h
index f7ae2286544c17ee0118eb3d2352f0cfd5faa914..f7f22c286a0dd9d381700af19b168f03256b6a09 100644
--- a/log/include/ana/pfet6.h
+++ b/include/ana/pfet6.h
@@ -5,10 +5,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_PFET6_INITLIB_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/pfet7f.h b/include/ana/pfet7f.h
similarity index 63%
rename from log/include/ana/pfet7f.h
rename to include/ana/pfet7f.h
index f1032f4f6e49695a348092923e60f482359c0474..fdd8f050883e9f62527138f35cd832be9dfa81f5 100644
--- a/log/include/ana/pfet7f.h
+++ b/include/ana/pfet7f.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_PFET7F_INITLIB_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/pfet7t.h b/include/ana/pfet7t.h
similarity index 63%
rename from log/include/ana/pfet7t.h
rename to include/ana/pfet7t.h
index 96d5c8813d03797e926aa46c323df94838f8f774..17901e1af2f3a3749aff103b76f9d651d15ec7da 100644
--- a/log/include/ana/pfet7t.h
+++ b/include/ana/pfet7t.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_PFET7T_INITLIB_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/physical.h b/include/ana/physical.h
similarity index 64%
rename from log/include/ana/physical.h
rename to include/ana/physical.h
index cf3240969f1105af06295a3154c07fced1240efd..d40db55a48c92a4a869133958733b81e2df80301 100644
--- a/log/include/ana/physical.h
+++ b/include/ana/physical.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_PHYSICAL_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/pnp1.h b/include/ana/pnp1.h
similarity index 62%
rename from log/include/ana/pnp1.h
rename to include/ana/pnp1.h
index b13c62556ec3ba26529f8171b688b6b18a3f7e35..bb1189256d4c8f174c7baa3b505e105bc9bdf978 100644
--- a/log/include/ana/pnp1.h
+++ b/include/ana/pnp1.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_PNP1_INITLIB_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/pnp2.h b/include/ana/pnp2.h
similarity index 63%
rename from log/include/ana/pnp2.h
rename to include/ana/pnp2.h
index 92596dffb81d17ff7021bb9421fb26862b4ccf10..109f486752baedcc77f85884ad5a0fc261aa338c 100644
--- a/log/include/ana/pnp2.h
+++ b/include/ana/pnp2.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_PNP2_INITLIB_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/pspc1.h b/include/ana/pspc1.h
similarity index 63%
rename from log/include/ana/pspc1.h
rename to include/ana/pspc1.h
index e28e3d427d6d909da1ea4dabee7bb5c1f6a870c6..aece7c5024eb79663c2631ec10d71e963ad9aa48 100644
--- a/log/include/ana/pspc1.h
+++ b/include/ana/pspc1.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_PSPC1_INITLIB_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/pwl.h b/include/ana/pwl.h
similarity index 62%
rename from log/include/ana/pwl.h
rename to include/ana/pwl.h
index 72d36487583bf69c46eb9ab2e17020856bc18058..0e9492187b074eab326012dcfcf9e9e805a1ffb7 100644
--- a/log/include/ana/pwl.h
+++ b/include/ana/pwl.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_pwl_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/resfloat.h b/include/ana/resfloat.h
similarity index 69%
rename from log/include/ana/resfloat.h
rename to include/ana/resfloat.h
index b6d1dfc48b94b0231398112dedfc6f5379447baf..d40995576678f340d7893b50245c2ad0fd704db3 100644
--- a/log/include/ana/resfloat.h
+++ b/include/ana/resfloat.h
@@ -6,10 +6,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_resfloat_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/rtd.h b/include/ana/rtd.h
similarity index 62%
rename from log/include/ana/rtd.h
rename to include/ana/rtd.h
index 97076b68273832c645153756d6259aa08d47f00e..112f1684981d54fd0c34ea65c00c6f662bd7e4e1 100644
--- a/log/include/ana/rtd.h
+++ b/include/ana/rtd.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_rtd_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/runspec.h b/include/ana/runspec.h
similarity index 64%
rename from log/include/ana/runspec.h
rename to include/ana/runspec.h
index 84e18b6ef52dc4122edf6a737f7524c0138b7fb7..396f7d5cd512d5160aa4a8544097ede2876c3bca 100644
--- a/log/include/ana/runspec.h
+++ b/include/ana/runspec.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_RUNSPEC_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/stairs.h b/include/ana/stairs.h
similarity index 63%
rename from log/include/ana/stairs.h
rename to include/ana/stairs.h
index 75de4c081fc156ea0ed12f74afc4e0793050403b..26ac27554e38cb26df5571c3b1d88336ecfb926b 100644
--- a/log/include/ana/stairs.h
+++ b/include/ana/stairs.h
@@ -5,10 +5,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_stairs_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/tc.h b/include/ana/tc.h
similarity index 76%
rename from log/include/ana/tc.h
rename to include/ana/tc.h
index 84bdfef33a0045b459c8d2d9dd3ad185ceb4e82a..38ffd904d47728a2c78d5cbb5f3cf3f6a428a6a1 100644
--- a/log/include/ana/tc.h
+++ b/include/ana/tc.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_opamp_initlib_32 (Analog_32_action *act);
 extern void Log_wramp_initlib_32 (Analog_32_action *act);
diff --git a/log/include/ana/thermal.h b/include/ana/thermal.h
similarity index 64%
rename from log/include/ana/thermal.h
rename to include/ana/thermal.h
index d21b80c31f25702513a26a43b3a1e467d21954cd..10cf2cb283dc2f86bda209c2869ca95b1a73dc3a 100644
--- a/log/include/ana/thermal.h
+++ b/include/ana/thermal.h
@@ -4,10 +4,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_THERMAL_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/vdiff.h b/include/ana/vdiff.h
similarity index 68%
rename from log/include/ana/vdiff.h
rename to include/ana/vdiff.h
index 7ae164693406f5960f75509d51062bd684a01eae..46ded4bf3f5b02663e46ca905b86f096636e54c9 100644
--- a/log/include/ana/vdiff.h
+++ b/include/ana/vdiff.h
@@ -6,10 +6,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 extern void Log_vdiff_initlib_32 (Analog_32_action *act);
 
diff --git a/log/include/ana/vswitch.h b/include/ana/vswitch.h
similarity index 69%
rename from log/include/ana/vswitch.h
rename to include/ana/vswitch.h
index ddc3e902916b61eb88efb1318adf822c6a3b26c8..3d46a429ac72b54d5410cc258def404540eb524a 100644
--- a/log/include/ana/vswitch.h
+++ b/include/ana/vswitch.h
@@ -5,10 +5,10 @@
 #include "logdef.h"
 #include "ana/nsolver.h"
 #include "ana/globals.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/sysglobals.h>
-#include <p2c/newci.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <utils/sysglobals.h>
+#include <graphics/newci.h>
 
 
 extern void Log_vswitch_initlib_32 (Analog_32_action *act);
diff --git a/log/include/gate.h b/include/gate.h
similarity index 96%
rename from log/include/gate.h
rename to include/gate.h
index 7702285735b539e630b6c5e23e67a046e2900b2e..7f09075c9dc4c5b4aa017fb6c75755ccb2814e6d 100644
--- a/log/include/gate.h
+++ b/include/gate.h
@@ -1,8 +1,8 @@
 #ifndef GATE_H
 #define GATE_H
 
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
 #include "logdef.h"
 
 typedef struct log_grec {
diff --git a/include/graphics/mylib.h b/include/graphics/mylib.h
new file mode 100644
index 0000000000000000000000000000000000000000..d98589d7957e3ecc8f15a9faf9c35911c978d999
--- /dev/null
+++ b/include/graphics/mylib.h
@@ -0,0 +1,173 @@
+#ifndef MYLIB_H
+#define MYLIB_H
+
+#include <X11/Xlib.h>
+
+typedef uchar m_colorarray[17];
+
+typedef uchar m_vcolorarray[1000001L];
+
+typedef struct m_chpicrec {
+    int xsize : 8, ysize : 8, xoff : 8, yoff : 8;
+    unsigned xdim : 8, ydim : 8, width : 8, height : 8;
+    long pic[32];
+} m_chpicrec;
+
+typedef struct m_cchpicrec {
+    int xsize : 8, ysize : 8, xoff : 8, yoff : 8;
+    unsigned xdim : 8, ydim : 8, width : 8, height : 8;
+    uchar pic[32][32];
+} m_cchpicrec;
+
+typedef struct m_tablet_info {
+    long x, y;
+    short phx, phy, fill1;
+    int ax : 8, ay : 8;
+    unsigned menu : 8, depressed : 1, near_ : 1, dn : 1, up : 1, off : 1, clip : 1,
+             moving : 1, inalpha : 1;
+} m_tablet_info;
+
+
+
+#define m_black         0
+#define m_red           1
+#define m_green         2
+#define m_yellow        3
+#define m_blue          4
+#define m_purple        5
+#define m_cyan          6
+#define m_white         7
+#define m_xblack        16
+#define m_xred          17
+#define m_xgreen        18
+#define m_xyellow       19
+#define m_xblue         20
+#define m_xpurple       21
+#define m_xcyan         22
+#define m_xwhite        23
+#define m_normal        0
+#define m_xor           16
+#define m_over          32
+#define m_mask          48
+#define m_add           64
+#define m_sub           80
+#define m_user          96
+
+#define m_scan          0xf8f8L
+#define m_erase         0xf9f9L
+#define m_hitdet        0xfafaL
+#define m_chg           0xfbfbL
+#define m_chgtab        0xfcfcL
+#define m_pat           0xfdfdL
+#define m_fastu         0xfefeL
+#define m_trans         0xffffL
+
+#define m_mode          256
+#define m_rule_erase    0
+#define m_rule_and      1
+#define m_rule_normal   3
+#define m_rule_mask     4
+#define m_rule_trans    5
+#define m_rule_xor      6
+#define m_rule_over     7
+#define m_rule_not      10
+#define m_rule_inv      12
+#define m_rule_ones     15
+#define m_pie           1
+#define m_chord         2
+#define m_extarc        3
+
+#define       DISPLAY_NAME_LENGTH 100
+
+long m_hitcount, m_across, m_down;
+long m_maxcolor;
+Display *m_display;
+Window m_window;
+int m_initialized;
+int BlackAndWhite;
+int screennum;
+
+#define ColorsInSet           16
+#define ColorSets              4
+XColor m_colors[ColorSets+1][ColorsInSet];
+
+/* Added X display name support.  stafford 7/17/91 */
+void m_set_display_name(char* display_name);
+char m_display_name[DISPLAY_NAME_LENGTH];
+int m_autoraise;
+
+void m_init_screen ();
+void m_init_colors ();
+void m_init_pen (int);
+void m_init_graphics ();
+void m_clear ();
+void m_clip (int, int, int, int);
+void m_noclip ();
+void m_unclip();	
+void m_transform (int, int, int, int, int, int, int);
+void m_upside_down ();
+void m_rotscale (double, double, int, int);
+void m_rotscaled (double, double, int, int);
+void m_notransform ();
+void m_untransform();
+void m_cursor (int, int);
+void m_nocursor ();
+void m_choosecursor (int);
+void m_color (int);
+void m_colormode (int c);
+long m_curcolor ();
+long m_curcolormode ();
+void m_setcolor();
+void m_seecolor (int, int *, int *, int *);
+void m_setcolors (m_colorarray, m_colorarray, m_colorarray);
+void m_seecolors (m_colorarray, m_colorarray, m_colorarray);
+void m_vsetcolors (int, int, m_vcolorarray, m_vcolorarray, m_vcolorarray);
+void m_vseecolors (int, int, m_vcolorarray, m_vcolorarray, m_vcolorarray);
+void m_choosecolors (int);
+void m_linestyle (int);
+void m_setlinestyle (int, int);
+void m_move (int, int);
+void m_move2 (int, int);
+void m_draw (int, int);
+void m_drawrel (int, int);
+void m_drawline (int, int, int, int);
+void m_drawrect (int, int, int, int);
+void m_fillrect (int, int, int, int);
+void m_grid (int, int, int, int, int, int, int, int);
+void m_drawpoint (int, int);
+void m_circle (int, int, int);
+void m_ellipse (int, int, int, int, int);
+void m_drawarc (long, long, long, long, double, double, double, long);
+void m_fillarc (long, long, long, long, double, double, double, long);
+void m_roundrect (int, int, int, int, int, int, int);
+void m_bezier (int, int, int, int, int, int, int, int);
+void m_bezier2 (int, int, int, int, int, int, int, int, int);
+void m_cbezier (int, int, int, int, int, int, int, int, int);
+void m_polycurve (double, double, double, double, double, double, double, double, double, double, double, double);
+void m_drawpoly (int, int [], int []);
+void m_fillpoly (int, int [], int []);
+void m_drawstr (int, int, char *, char *);
+void m_centerstr (int, int, char *, char *);
+void m_rightstr (int, int, char *, char *);
+long m_strwidth (char *, char *);
+void m_setfont();
+void m_seefont();
+void m_graphics_on();
+void m_alpha_on();
+
+#define m_graphics_off()
+#define m_alpha_off()
+
+void m_readpen();
+void m_trackpen();
+void m_waitpen();
+void m_clipxy();
+int m_pollkbd();
+uchar m_inkey();
+uchar m_inkeyn();
+uchar m_testkey();
+
+#endif /*MYLIB_H*/
+
+/* End. */
+
diff --git a/include/graphics/newci.h b/include/graphics/newci.h
new file mode 100644
index 0000000000000000000000000000000000000000..b8e9c00a6c5f2bcfb7daa78bd5d1280b8297e215
--- /dev/null
+++ b/include/graphics/newci.h
@@ -0,0 +1,36 @@
+#ifndef NEWCI_H
+#define NEWCI_H
+
+typedef struct newci_parserec {
+	char switch_[4];
+	size_t used;
+	char kind; /* kind of union below */
+	union {
+		long i;
+		double r;
+		char *s;
+	} UU;
+} newci_parserec;
+
+int P_argc;
+char **P_argv;
+
+void newci_parseswitch (newci_parserec *tab, size_t size, char *bad);
+void newci_eatargument ();
+void newci_fixfname (char *s, char *ext, char *home);
+void newci_forcefname (char *s, char *ext, char *home);
+void newci_shellescape (char *args);
+void newci_fullshellescape (char *args, char *opts);
+void newci_fulleditescape (char *fn, char *opts, long ln, long pos);
+void newci_nullrecover ();
+
+void newci_inputmap ();
+void newci_inputunmap ();
+void newci_inputstring (char *s);
+long timers_sysclock ();
+long newci_fullseconds ();
+
+#endif /*NEWCI_H*/
+
+/* End. */
+
diff --git a/include/graphics/newcrt.h b/include/graphics/newcrt.h
new file mode 100644
index 0000000000000000000000000000000000000000..2b2445127593ec1dbf2ec19e72a324e1ecbd9f25
--- /dev/null
+++ b/include/graphics/newcrt.h
@@ -0,0 +1,246 @@
+#ifndef NEWCRT_H
+#define NEWCRT_H
+#include <X11/Xlib.h>
+
+/* Caged_date="r      nc_revision='V1.01: $X';" */
+#define nc_revision     "V1.01: Dec 17, 1988 11:00 pm"
+
+
+short XPOS, YPOS;
+
+/* Window stuff */
+/* Maybe use this info?? */
+/* Graphics window */
+/* Clip region */
+/* Offsets to add for gLine */
+/* Saved values of xpos, ypos */
+/*Number of bytes needed to save window*/
+/*NIL or pointer to save area*/
+
+typedef struct nc_windowRec {
+    short top, height, left, width;
+    long area;
+    short font, gcolor, gtop, gheight, gleft, gwidth, gminx, gmaxx, gminy,
+	  gmaxy, goffx, goffy, savex, savey, saveHigh;
+    long saveSize;
+    void* *saveArea;
+} nc_windowRec;
+
+
+
+/* newCrt-4  */
+/* newCrt-8  */
+/* newCrt-12 */
+/* newCrt-16 */
+/* newCrt-20 */
+/* Character re-mapping stuff */
+
+typedef short nc_maparray[256];
+
+
+
+/* newCrt-22  NOT USED ANY MORE */
+/* newCrt-26  NOT USED ANY MORE */
+/* newCrt-28 */
+/* newCrt-30 */
+/* Font information */
+#define nc_maxFonts     4
+
+
+
+typedef struct nc_fontRec {
+    short foffset, fwidth, fheight;
+} nc_fontRec;
+
+
+
+/*nc_windows : array[0..nc_maxWindows] of nc_windowRec;*/
+/* Exciting colors */
+#define nc_green        0
+#define nc_yellow       4096
+#define nc_black        8192
+#define nc_red          12288
+#define nc_cyan         16384
+#define nc_white        20480
+#define nc_blue         24576
+#define nc_purple       28672
+
+/* Exciting attributes */
+#define nc_inv          256
+#define nc_blink        512
+#define nc_under        1024
+#define nc_half         2048
+
+/* Exciting displays */
+#define nc_g26          0
+#define nc_g36          2
+#define nc_g36c         4
+#define nc_g300         6
+
+/* #define nc_fontwidth 8 */
+#define nc_fontwidth 8 
+#define nc_fontheight 13
+
+
+/* Command translation */
+
+typedef char nc_commandArray[256];
+
+
+
+/* Things to deal with graphics junk left on screen */
+/* Information about graphics VS alpha screen stuff */
+/* left edge of main window */
+/* top of main window */
+/* pixels/character in X */
+/* pixels/character in Y */
+/* real width of hardware */
+/* real height of hardware */
+/* number of graphics colors */
+/* number of available graphics colors */
+
+typedef union nc_crtword {
+    struct {
+      char h, c;
+    } U1;
+    short i;
+} nc_crtword;
+
+typedef nc_crtword nc_scrtype[];
+
+
+
+/* call nc_refreshXY, etc after changing! */
+/* New, improved Colors to eliminate Mylib conflicts. */
+
+typedef uchar nc_colorarray[3][256];
+
+
+#ifndef NEWCRT_G
+nc_windowRec *nc_curWindow;
+nc_windowRec *nc_mainWindow, *nc_lastLineWindow, *nc_statusWindow,
+                    *nc_defaultWindow;
+#endif
+int nc_text_in_window;
+Window nc_window;
+int nc_initialized;
+GC nc_gc;
+short nc_highlight, nc_defaultHighlight;
+nc_windowRec *nc_tempWindow;
+nc_fontRec nc_fonts[nc_maxFonts + 1];
+char *nc_commands;
+_PROCEDURE nc_startAlphaHook, nc_endAlphaHook;
+struct {
+    short left, top, xincr, yincr, width, height, colors, gColors;
+} nc_g;
+nc_crtword *nc_screen;
+uchar (*nc_colors)[256];
+
+
+
+/* Simulation routines.  Should GO AWAY. */
+void nc_scrollDown ();
+void nc_scrollUp ();
+void nc_setWindow (int s, int l);
+void nc_revCheck (char *rev);
+void nc_setbeep (int b);
+short nc_getNumPlanes ();
+short nc_getAlphaPlanes ();
+void nc_setAlphaPlanes (int num);
+short nc_getGraphicsPlanes ();
+void nc_setGraphicsPlanes (int num);
+int nc_alphashared ();
+void nc_sharealpha (int b);
+void nc_setAlpha (int on);
+void nc_setGraphics (int on);
+short nc_getPlanes ();
+void nc_setPlanes (int mask);
+void nc_putChar (int x, int y, int c);
+void nc_putChars (int x, int y, int len, char *c);
+void nc_putStr (int x, int y, char *s);
+void nc_writeStr (int x, int y, char *s);
+char nc_getChar (int x, int y);
+void nc_getChars (int x, int y, int len, char *c);
+void nc_getStr (int x, int y, char *s);
+short nc_getHighlight (int x, int y);
+void nc_setHighlight (int high);
+void nc_writeHighlight (int x, int y, int len, int newhigh);
+void nc_orHighlight (int x, int y, int len, int newhigh);
+void nc_andnotHighlight (int x, int y, int len, int newhigh);
+void nc_putWord (int x, int y, int w);
+void nc_putWords (int x, int y, int len, short *w);
+short nc_getWord (int x, int y);
+void nc_getWords (int x, int y, int len, short *w);
+void nc_makeWindow (nc_windowRec *w, int ptop, int pheight,
+			      int pleft, int pwidth);
+void nc_setWindow_ (nc_windowRec *w);
+void nc_saveWindow ();
+void nc_restoreWindow ();
+void nc_exchangeWindow ();
+void nc_refreshON ();
+void nc_refreshOFF ();
+void nc_refreshXY (int x, int y, int dx, int dy);
+void nc_refreshWindow ();
+void nc_refreshScreenXY (int x, int y, int dx, int dy);
+void nc_refreshScreen ();
+short nc_gType ();
+void nc_aCMap (int col, int r, int g, int b);
+void nc_defaCMap ();
+void nc_gCMap (int col, int r, int g, int b);
+void nc_defgCMap ();
+void nc_gColor (int col);
+void nc_gLine (int x1, int y1, int x2, int y2);
+void nc_gFillRect (int x1, int y1, int x2, int y2);
+void nc_gBlit (int repl_rule, int dox, int doy, int sox, int soy,
+			 int width, int height);
+void nc_gClear ();
+void nc_gClipToWindow (int x1, int y1, int x2, int y2);
+void nc_gClipToHardware (int x1, int y1, int x2, int y2);
+void nc_clearXY (int x, int y, int dx, int dy);
+void nc_clear ();
+void nc_scrollUp_ ();
+void nc_scrollDown_ ();
+void nc_scrollLeft ();
+void nc_scrollRight ();
+void nc_scrollXY (int dx, int dy);
+void nc_insChar (int x, int y, int numChars);
+void nc_insLine (int y, int numLines);
+void nc_getXY (long *x, long *y);
+void nc_setXY (int x, int y);
+void nc_gotoXY (int x, int y);
+void nc_cursXY (int x, int y);
+void nc_cursorOn ();
+void nc_cursorOff ();
+void nc_nothing ();
+void nc_unInit ();
+void nc_init ();
+void nc_setDevice (long newDevice);
+
+char *nc_fgets (char *s, int n, FILE *stream);
+char *nc_gets (char *s);
+
+/* added for C99 clang compatibility */
+
+void nc_putc (uchar c, FILE * outfile);
+void nc_putchar (uchar c);
+void nc_puts (char * s);
+void nc_fputs (char * s, FILE *outfile);
+
+void nc_printf (char * fmt, ...);
+void nc_fprintf (FILE * outfile, char * fmt, ...);
+
+#define printf nc_printf 
+#define fprintf nc_fprintf 
+#define puts nc_puts
+#undef putchar
+#define putchar nc_putchar
+#undef putc
+#define putc nc_putc
+#define fputs nc_fputs
+#define gets nc_gets
+#define fgets nc_fgets
+
+#endif /*NEWCRT_H*/
+
+/* End. */
+
diff --git a/psys/include/p2c/newkbd.h b/include/graphics/newkbd.h
similarity index 76%
rename from psys/include/p2c/newkbd.h
rename to include/graphics/newkbd.h
index e59021d319ecce3d220b4834e304c8da0e55cd60..0ec873d702ac8c2f5f420192eaeb1e9ba525c212 100644
--- a/psys/include/p2c/newkbd.h
+++ b/include/graphics/newkbd.h
@@ -2,15 +2,9 @@
 #define NEWKBD_H
 
 
-#include <p2c/sysglobals.h>
-#include <p2c/sysdevs.h>
-#include <p2c/misc.h>
-
-#ifdef NEWKBD_G
-#define vextern
-#else
-#define vextern extern
-#endif
+#include <utils/sysglobals.h>
+#include <utils/sysdevs.h>
+#include <utils/misc.h>
 
 #define nk_keylow       (-2)
 #define nk_keyhigh      125
@@ -46,19 +40,17 @@ typedef struct nk_keytransinfo {
     short rpgbufsize;
 } nk_keytransinfo;
 
-vextern int nk_capslock;
+int nk_capslock;
 
 #define nk_keybufsize m_pollkbd
-extern void nk_keybufclear ();
+void nk_keybufclear ();
 #define nk_getkey m_inkey
-extern void nk_ungetkey (int c);
+void nk_ungetkey (uchar c);
 #define nk_testkey(x)        m_testkey()
 #define nk_gotoxy(x,y)      nc_gotoXY(x,y)
 #define nk_getxy(x,y)       nc_getXY(x,y)
-extern int nk_setcapslock (int newcaps);
-extern void nk_settransarray (int opcode, nk_keytransinfo **table);
-
-#undef vextern
+int nk_setcapslock (int newcaps);
+void nk_settransarray (int opcode, nk_keytransinfo **table);
 
 #endif /*NEWKBD_H*/
 
diff --git a/log/include/help.h b/include/help.h
similarity index 100%
rename from log/include/help.h
rename to include/help.h
diff --git a/log/include/label.h b/include/label.h
similarity index 100%
rename from log/include/label.h
rename to include/label.h
diff --git a/log/include/log.h b/include/log.h
similarity index 98%
rename from log/include/log.h
rename to include/log.h
index 335703fb8ae5a8b522711090fed411bc033e98bf..507c3b68b640a6781b13e13302d6e8b9679c4281 100644
--- a/log/include/log.h
+++ b/include/log.h
@@ -1,7 +1,7 @@
 #ifndef LOG_H
 #define LOG_H
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "logdef.h"
 #include "logstructs.h"
 #include "wire.h"
diff --git a/log/include/log_action.h b/include/log_action.h
similarity index 99%
rename from log/include/log_action.h
rename to include/log_action.h
index d497c141cd588020bf0ebfca5d3d5ca56579aea9..135a7cee1ba06b9336087801ee2e0fc0bd78f257 100644
--- a/log/include/log_action.h
+++ b/include/log_action.h
@@ -310,8 +310,6 @@ typedef struct log_action_t
 
 	FILE **tracefile;
 
-	long rndseed; /** Seed for RAND funtion */
-
 	char *homedirname;
 
 	enum
diff --git a/log/include/logcom.h b/include/logcom.h
similarity index 72%
rename from log/include/logcom.h
rename to include/logcom.h
index c7a6e6602ac7c143ab0a4299d22847fccaefe837..a97ea45e24a40c82f64a8605bda8c0635e93de3f 100644
--- a/log/include/logcom.h
+++ b/include/logcom.h
@@ -2,11 +2,11 @@
 #define LOGCOM_H
 
 #include "logdef.h"
-#include <p2c/mylib.h>
-#include <p2c/newasm.h>
-#include <p2c/newkbd.h>
-#include <p2c/newci.h>
-#include <p2c/sysdevs.h>
+#include <graphics/mylib.h>
+#include <utils/newasm.h>
+#include <graphics/newkbd.h>
+#include <graphics/newci.h>
+#include <utils/sysdevs.h>
 
 extern void Log_0_proc (log_action_t *act);
 extern void Log_1_proc (log_action_t *act);
diff --git a/log/include/logcurs_arr.h b/include/logcurs_arr.h
similarity index 100%
rename from log/include/logcurs_arr.h
rename to include/logcurs_arr.h
diff --git a/log/include/logcurs_box.h b/include/logcurs_box.h
similarity index 100%
rename from log/include/logcurs_box.h
rename to include/logcurs_box.h
diff --git a/log/include/logcurs_cpy.h b/include/logcurs_cpy.h
similarity index 100%
rename from log/include/logcurs_cpy.h
rename to include/logcurs_cpy.h
diff --git a/log/include/logcurs_del.h b/include/logcurs_del.h
similarity index 100%
rename from log/include/logcurs_del.h
rename to include/logcurs_del.h
diff --git a/log/include/logcurs_prb.h b/include/logcurs_prb.h
similarity index 100%
rename from log/include/logcurs_prb.h
rename to include/logcurs_prb.h
diff --git a/log/include/logdef.h b/include/logdef.h
similarity index 98%
rename from log/include/logdef.h
rename to include/logdef.h
index cc9aa2e027042db17e1b08467919138fd30154bf..b13f04ca87f3e0c5b0cfbb8d305e736c40acd925 100644
--- a/log/include/logdef.h
+++ b/include/logdef.h
@@ -1,10 +1,10 @@
 #ifndef LOGDEF_H
 #define LOGDEF_H
 
-#include <p2c/p2c.h>
-#include <p2c/mylib.h>
-#include <p2c/strlist.h>
-#include <p2c/newasm.h>
+#include <utils/p2c.h>
+#include <graphics/mylib.h>
+#include <utils/strlist.h>
+#include <utils/newasm.h>
 
 #ifdef LOGDEF_G
 # define vextern
diff --git a/log/include/logdig.h b/include/logdig.h
similarity index 98%
rename from log/include/logdig.h
rename to include/logdig.h
index d4a90c25b57e5a4dd4e95f4fd5bd334c2586e8f1..abda1e368d1f2e64d0ad95aa1f2fe1bffe2a3bd4 100644
--- a/log/include/logdig.h
+++ b/include/logdig.h
@@ -2,7 +2,7 @@
 #define LOGDIG_H
 
 #include "logdef.h"
-#include <p2c/sysglobals.h>
+#include <utils/sysglobals.h>
 
 #ifdef LOGDIG_G
 # define vextern
diff --git a/log/include/logfont.h b/include/logfont.h
similarity index 100%
rename from log/include/logfont.h
rename to include/logfont.h
diff --git a/log/include/logglobals.h b/include/logglobals.h
similarity index 98%
rename from log/include/logglobals.h
rename to include/logglobals.h
index 4e54faebc7efc31935e1d7e0cabc762e6fa2d938..f400faef1dd166438ba2561ca767a876f4e3389e 100644
--- a/log/include/logglobals.h
+++ b/include/logglobals.h
@@ -1,15 +1,12 @@
 #ifndef LOGGLOBALS
 #define LOGGLOBALS
 
-#include <p2c/p2c.h>
-#include <p2c/newkbd.h>
+#include <utils/p2c.h>
+#include <graphics/newkbd.h>
 #include "settings.h"
 #include "logstructs.h"
 
 extern char *GetChipmunkPath();
-#define newci_findprocedure2  findprocedure
-extern int findprocedure (char *name, void (**start)());
-
 
 /* 0*/
 /* If the pen is in "this" sector, */
diff --git a/log/include/loghier.h b/include/loghier.h
similarity index 94%
rename from log/include/loghier.h
rename to include/loghier.h
index 6b2adc20ccf74a0cb5d02ad6765c446a1e1365f3..6ff42d90d3e23f7ace7898351807bf2827dfd236 100644
--- a/log/include/loghier.h
+++ b/include/loghier.h
@@ -2,8 +2,8 @@
 #define LOGHIER_H
 
 #include "logdef.h"
-#include <p2c/newasm.h>
-#include <p2c/mylib.h>
+#include <utils/newasm.h>
+#include <graphics/mylib.h>
 typedef short log_shintarray[log_million];
 
 
diff --git a/include/logntk.h b/include/logntk.h
new file mode 100644
index 0000000000000000000000000000000000000000..b7190205baa72d7ebd54ec14f1751cd2f87858db
--- /dev/null
+++ b/include/logntk.h
@@ -0,0 +1,17 @@
+#ifndef LOGNTK_H
+#define LOGNTK_H
+
+#include "logdef.h"
+#include "loghier.h"
+#include <utils/newasm.h>
+#include <graphics/newkbd.h>
+#include <graphics/newci.h>
+#include <graphics/newcrt.h>
+#include <graphics/mylib.h>
+#include <utils/regex.h>
+
+extern void Log_logntk_proc (log_action_t *act);
+
+#endif /*LOGNTK_H*/
+
+/* End. */
diff --git a/log/include/logsim.h b/include/logsim.h
similarity index 84%
rename from log/include/logsim.h
rename to include/logsim.h
index 8484dfafaee330773b866b80d2f8f937679bb714..c66da0795fd5508b06fec0367e7fdfa26ba2c7ca 100644
--- a/log/include/logsim.h
+++ b/include/logsim.h
@@ -6,12 +6,11 @@
 #include "logdig.h"
 #include "logsima.h"
 #include "logsimed.h"
-#include <p2c/rnd.h>
-#include <p2c/newkbd.h>
-#include <p2c/newasm.h>
-#include <p2c/newci.h>
-#include <p2c/newcrt.h>
-#include <p2c/mylib.h>
+#include <graphics/newkbd.h>
+#include <utils/newasm.h>
+#include <graphics/newci.h>
+#include <graphics/newcrt.h>
+#include <graphics/mylib.h>
 
 extern void Log_16_proc (log_action_t *lact);
 extern void Log_16_7seg (log_16_action *act);
diff --git a/log/include/logsima.h b/include/logsima.h
similarity index 97%
rename from log/include/logsima.h
rename to include/logsima.h
index c3536576031bdf774c52444d367d7b684151e222..03d279771c1dc47a72e8e6b81ef0242a06806e42 100644
--- a/log/include/logsima.h
+++ b/include/logsima.h
@@ -4,7 +4,7 @@
 #include "logsim.h"
 #include "logdef.h"
 #include "logdig.h"
-#include <p2c/newasm.h>
+#include <utils/newasm.h>
 
 
 #ifdef LOGSIMA_G
diff --git a/log/include/logsimed.h b/include/logsimed.h
similarity index 82%
rename from log/include/logsimed.h
rename to include/logsimed.h
index 1070a704a73964508ee80412c0fe938e440a436d..2b088623094f8df72d8fb2b2be59f13f2fc350ea 100644
--- a/log/include/logsimed.h
+++ b/include/logsimed.h
@@ -4,10 +4,10 @@
 
 #include "logdef.h"
 #include "logdig.h"
-#include <p2c/newkbd.h>
-#include <p2c/newasm.h>
-#include <p2c/newci.h>
-#include <p2c/newcrt.h>
+#include <graphics/newkbd.h>
+#include <utils/newasm.h>
+#include <graphics/newci.h>
+#include <graphics/newcrt.h>
 
 
 extern void edit_16 (uchar **proc, long *proclen, char *name);
diff --git a/log/include/logsimh.h b/include/logsimh.h
similarity index 79%
rename from log/include/logsimh.h
rename to include/logsimh.h
index 17024c1f555913485165731757db45fa1db97eba..89a940d18ff165aaa7e1220942cdb9e90400320c 100644
--- a/log/include/logsimh.h
+++ b/include/logsimh.h
@@ -6,9 +6,9 @@
 #include "logdig.h"
 #include "logsima.h"
 #include "logsimed.h"
-#include <p2c/newasm.h>
-#include <p2c/newci.h>
-#include <p2c/mylib.h>
+#include <utils/newasm.h>
+#include <graphics/newci.h>
+#include <graphics/mylib.h>
 
 extern void Log_16_inst (log_16_action *act);
 extern void Log_dig_inst (log_16_action *act);
diff --git a/include/logspc.h b/include/logspc.h
new file mode 100644
index 0000000000000000000000000000000000000000..6f18ad366340cf9e325a870a06d002f49d0dcaeb
--- /dev/null
+++ b/include/logspc.h
@@ -0,0 +1,17 @@
+#ifndef LOGSPC_H
+#define LOGSPC_H
+
+#include "logdef.h"
+#include "loghier.h"
+#include <utils/newasm.h>
+#include <graphics/newkbd.h>
+#include <graphics/newci.h>
+#include <graphics/newcrt.h>
+#include <graphics/mylib.h>
+#include <utils/regex.h>
+
+extern void Log_logspc_proc (log_action_t *act);
+
+#endif /*LOGSPC_H*/
+
+/* End. */
diff --git a/log/include/logstructs.h b/include/logstructs.h
similarity index 100%
rename from log/include/logstructs.h
rename to include/logstructs.h
diff --git a/log/include/logstuff.h b/include/logstuff.h
similarity index 100%
rename from log/include/logstuff.h
rename to include/logstuff.h
diff --git a/log/include/mygates.h b/include/mygates.h
similarity index 77%
rename from log/include/mygates.h
rename to include/mygates.h
index bc0a5588b1511ae8ecbdbfa10476fa069558f211..f8579634d55dc9eef650b42492adf372f9f784b6 100644
--- a/log/include/mygates.h
+++ b/include/mygates.h
@@ -4,9 +4,9 @@
 
 #include "logdef.h"
 #include "logdig.h"
-#include <p2c/newasm.h>
-#include <p2c/newci.h>
-#include <p2c/mylib.h>
+#include <utils/newasm.h>
+#include <graphics/newci.h>
+#include <graphics/mylib.h>
 
 extern void Log_mygates_sram8k (log_16_action *act);
 extern void Log_mygates_ascdisp (log_16_action *act);
diff --git a/log/include/node.h b/include/node.h
similarity index 100%
rename from log/include/node.h
rename to include/node.h
diff --git a/log/include/page.h b/include/page.h
similarity index 100%
rename from log/include/page.h
rename to include/page.h
diff --git a/log/include/pagereader.h b/include/pagereader.h
similarity index 100%
rename from log/include/pagereader.h
rename to include/pagereader.h
diff --git a/log/include/pagewriter.h b/include/pagewriter.h
similarity index 100%
rename from log/include/pagewriter.h
rename to include/pagewriter.h
diff --git a/log/include/screen.h b/include/screen.h
similarity index 100%
rename from log/include/screen.h
rename to include/screen.h
diff --git a/log/include/settings.h b/include/settings.h
similarity index 100%
rename from log/include/settings.h
rename to include/settings.h
diff --git a/log/include/swap.h b/include/swap.h
similarity index 93%
rename from log/include/swap.h
rename to include/swap.h
index 8f72d5e2b4810e0428fc54d5a3a8fed719cc91b6..78d6c6f87545d05cc2742d04408e27f89e16f22b 100644
--- a/log/include/swap.h
+++ b/include/swap.h
@@ -1,6 +1,6 @@
 #include <stdio.h>
 #include <ctype.h>
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 
 typedef union swap2 {
         short ival;
diff --git a/log/include/tool.h b/include/tool.h
similarity index 100%
rename from log/include/tool.h
rename to include/tool.h
diff --git a/log/include/utils.h b/include/utils.h
similarity index 100%
rename from log/include/utils.h
rename to include/utils.h
diff --git a/include/utils/filepack.h b/include/utils/filepack.h
new file mode 100644
index 0000000000000000000000000000000000000000..c9324c2008fd56cdc94cfb628e1e1ca1bf0e2c78
--- /dev/null
+++ b/include/utils/filepack.h
@@ -0,0 +1,12 @@
+#ifndef FILEPACK_H
+#define FILEPACK_H
+
+#include <utils/sysglobals.h>
+
+void fp_change (char *filename1, char *filename2);
+void fp_remove (char *filename);
+int fp_getwd (char *path, char *rootname);
+
+#endif /*FILEPACK_H*/
+
+/* End. */
diff --git a/psys/include/p2c/iodecl.h b/include/utils/iodecl.h
similarity index 91%
rename from psys/include/p2c/iodecl.h
rename to include/utils/iodecl.h
index 0493b74b39c4f55a16b95d1c94424c1b3f9f9fa5..50d275895313748e1f26414df6899363bb32cb7f 100644
--- a/psys/include/p2c/iodecl.h
+++ b/include/utils/iodecl.h
@@ -1,13 +1,6 @@
 #ifndef IODECLARATIONS_H
 #define IODECLARATIONS_H
 
-#ifdef IODECLARATIONS_G
-# define vextern
-#else
-# define vextern extern
-#endif
-
-
 #define P_iominisc      0
 #define P_iomaxisc      31
 #define P_minrealisc    7
@@ -225,23 +218,20 @@ typedef struct buf_info_type {
 
 
 
-vextern io_funny_proc dma_ch_0;
-vextern uchar dma_isc_0;
-vextern io_funny_proc dma_ch_1;
-vextern uchar dma_isc_1;
-vextern int dma_here;
-vextern char io_work_char;
-vextern long ioe_result, ioe_isc;
-vextern isc_table_type isc_table[P_iomaxisc - P_iominisc + 1];
-vextern char io_revid[97];
-vextern _PROCEDURE io_error_link;
-
-
-extern void io_escape (long my_code, long select_code);
-extern uchar io_find_isc (void* *iod_temp);
+io_funny_proc dma_ch_0;
+uchar dma_isc_0;
+io_funny_proc dma_ch_1;
+uchar dma_isc_1;
+int dma_here;
+char io_work_char;
+long ioe_result, ioe_isc;
+isc_table_type isc_table[P_iomaxisc - P_iominisc + 1];
+char io_revid[97];
+_PROCEDURE io_error_link;
 
 
-#undef vextern
+void io_escape (long my_code, long select_code);
+uchar io_find_isc (void* *iod_temp);
 
 #endif /*IODECLARATIONS_H*/
 
diff --git a/include/utils/misc.h b/include/utils/misc.h
new file mode 100644
index 0000000000000000000000000000000000000000..972bbe68f46f591eb6109c472655ca563eb16f1f
--- /dev/null
+++ b/include/utils/misc.h
@@ -0,0 +1,14 @@
+#ifndef MISC_H
+#define MISC_H
+
+/*homeless orphans*/
+#include <utils/sysglobals.h>
+
+/* idle character -- 3.0 bug jws 3/20/84 */
+void misc_getioerrmsg (char *s, long lastior);
+char *tilde_expand  (char *s);
+
+#endif /*MISC_H*/
+
+/* End. */
+
diff --git a/include/utils/newasm.h b/include/utils/newasm.h
new file mode 100644
index 0000000000000000000000000000000000000000..7f60a17d5daadf940d9a416e6923f8f6b74712d6
--- /dev/null
+++ b/include/utils/newasm.h
@@ -0,0 +1,28 @@
+#ifndef NEWASM_H
+#define NEWASM_H
+
+typedef void* na_long;
+
+void na_exch (long *s, long *d, long size);
+
+long na_log2 (long n);
+long na_po2 (long n);
+
+long na_bfextu (long *v, long offset, long size);
+
+long na_bfcount (long *v, long offset, long size);
+long na_setcard (long *s);
+
+long P_imax2 (long a, long b);
+long P_imin2 (long a, long b);
+void P_iswap2 (long *a, long *b);
+long P_ibound (long min, long i, long max);
+int P_ibetween (long min, long i, long max);
+int P_ibetweenm (long min, long i, long max, long margin);
+
+void* na_rtosr (double r);
+double na_srtor (void* sr);
+
+#endif /*NEWASM_H*/
+
+/* End. */
diff --git a/psys/include/p2c/p2c.h b/include/utils/p2c.h
similarity index 73%
rename from psys/include/p2c/p2c.h
rename to include/utils/p2c.h
index 2e2552637ead8a03acbbfeebb7048a2764fb3a0a..4e20a6af34a4e7da008c31ea3dddcdabecec2c25 100644
--- a/psys/include/p2c/p2c.h
+++ b/include/utils/p2c.h
@@ -19,7 +19,7 @@
 #include <assert.h>
 #include <stdbool.h>
 
-/* Funcition for compiler warnings*/
+/* Function for compiler warnings*/
 #ifdef __GNUC__
 #define DEPRECATED __attribute__((deprecated))
 #else
@@ -75,40 +75,40 @@ typedef struct {
 #endif
 
 
-extern void    PASCAL_MAIN   (int, char **);
-extern char    **P_argv;
-extern int     P_argc;
-extern short   P_escapecode;
-extern int     P_ioresult;
-extern __p2c_jmp_buf *__top_jb;
-extern int     bigendian;
-
-extern void*   _OutMem     ();
-extern void    _CaseCheck  ();
-extern void    _NilCheck   ();
-extern char   *_ShowEscape   (char *, int, int, char *);
-extern void	_Escape      (int);
-extern void	_EscIO       (int);
-
-extern int      microsleep    (long);
-
-extern char    *strsub       (char *, char *, size_t, size_t);
-extern char    *strltrim     (char *);
-extern char    *strrtrim     (char *);
-extern size_t  strpos2      (char *, char *, size_t);
-extern void    strmove      (size_t len, char * s, size_t spos, char * d, size_t dpos);
-extern int     strcicmp     (char * s1, char * s2);
-
-extern int      P_eof        (FILE *);
-extern int      P_eoln       (FILE *);
-extern long    *P_setunion   (long *, long *, long *) DEPRECATED;
-extern long    *P_setdiff    (long *, long *, long *) DEPRECATED;
-extern int      P_inset      (unsigned, long *) DEPRECATED;
-extern int      P_subset     (long *, long *) DEPRECATED;
-extern long    *P_addset     (long *, unsigned) DEPRECATED;
-extern long    *P_addsetr    (long *, unsigned, unsigned) DEPRECATED;
-extern long    *P_remset     (long *, unsigned) DEPRECATED;
-extern long    *P_expset     (long *, long) DEPRECATED;
+void    PASCAL_MAIN   (int, char **);
+char    **P_argv;
+int     P_argc;
+short   P_escapecode;
+int     P_ioresult;
+__p2c_jmp_buf *__top_jb;
+int     bigendian;
+
+void*   _OutMem     ();
+void    _CaseCheck  ();
+void    _NilCheck   ();
+char   *_ShowEscape   (char *, int, int, char *);
+void	_Escape      (int);
+void	_EscIO       (int);
+
+int      microsleep    (long);
+
+char    *strsub       (char *, char *, size_t, size_t);
+char    *strltrim     (char *);
+char    *strrtrim     (char *);
+size_t  strpos2      (char *, char *, size_t);
+void    strmove      (size_t len, char * s, size_t spos, char * d, size_t dpos);
+int     strcicmp     (char * s1, char * s2);
+
+int      P_eof        (FILE *);
+int      P_eoln       (FILE *);
+long    *P_setunion   (long *, long *, long *) DEPRECATED;
+long    *P_setdiff    (long *, long *, long *) DEPRECATED;
+int      P_inset      (unsigned, long *) DEPRECATED;
+int      P_subset     (long *, long *) DEPRECATED;
+long    *P_addset     (long *, unsigned) DEPRECATED;
+long    *P_addsetr    (long *, unsigned, unsigned) DEPRECATED;
+long    *P_remset     (long *, unsigned) DEPRECATED;
+long    *P_expset     (long *, long) DEPRECATED;
 
 /* I/O error handling */
 #define _SETIO(cond,ior)          (P_ioresult = (cond) ? 0 : (ior))
@@ -181,7 +181,7 @@ extern long    *P_expset     (long *, long) DEPRECATED;
 
 #if !defined(L_cuserid)
 #define L_cuserid 32
-extern char * cuserid(char *);
+char * cuserid(char *);
 #endif
 
 /* End. */
diff --git a/include/utils/regex.h b/include/utils/regex.h
new file mode 100644
index 0000000000000000000000000000000000000000..88554d21c6ee27fe701ad1b25811f1e915f23a06
--- /dev/null
+++ b/include/utils/regex.h
@@ -0,0 +1,26 @@
+#ifndef REGEX_H
+#define REGEX_H
+
+
+#include <utils/newasm.h>
+
+
+#define re_defchars     "\\[]^-*?+$.|~(){}:=<>"
+#define re_shellchars   "\\[]^-    ?       *  "
+
+void re_compile (char *ex, char *rex, char *chars);
+void re_cicompile (char *ex, char *rex, char *chars);
+void re_dump (char *rex);
+void re_search (char *s, char *rex, size_t *pos, size_t *last, size_t dir);
+int re_compare (char *s, char *rex);
+void re_replace (char *s, char *rex, char *rpl, size_t *pos,
+			   size_t *last);
+int re_matchstr (char *s, char *pat);
+int re_matchsubstr (char *s, char *pat, size_t start, size_t *last);
+void re_grepl (char *s, char *pat, char *rpl);
+
+
+#endif /*REGEX_H*/
+
+/* End. */
+
diff --git a/include/utils/strings.h b/include/utils/strings.h
new file mode 100644
index 0000000000000000000000000000000000000000..678c6fab6cf74c163b91d47b38ca2683a3eb3912
--- /dev/null
+++ b/include/utils/strings.h
@@ -0,0 +1,56 @@
+#ifndef P2C_STRING_H
+#define P2C_STRING_H
+
+#include <utils/p2c.h>
+
+/**
+ * Append the second string to the first.
+ *
+ * DEPRECATED : use strcat instead
+ */
+void strsafeappend(char *s, char *s2) DEPRECATED;
+
+//void strappendc(char *s, int ch);
+char *strupper (char *result, char *s);
+char *strlower (char *result, char *s);
+char *strpart (char *result, char *s, long fist, long last);
+char *strlast (char *result, char *s, size_t num);
+char *strreverse (char *result, char*);
+//char *strljust (char *result, char *s, long wid);
+//char *strrjust (char *result, char *s, long wid);
+char *strcjust (char *result, char *s, size_t wid);
+int strbegins (char *s1, char *s2);
+int strends (char *s1, char *s2);
+int strcibegins (char *s1, char *s2);
+int strciends (char *s1, char *s2);
+int strsubcmp (size_t n, char *s1, size_t i1, char *s2, size_t i2);
+int strcisubcmp (size_t n, char *s1, size_t i1, char *s2, size_t i2);
+void strsubst (char *repl, char *s, size_t index, size_t size);
+char *strint (char *result, long i);
+char *strint2 (char *result, long i, long w);
+//char *strreal (char *result, double r);
+char *strchar (char *result, int ch);
+//long strreadint (char *s);
+//double strreadreal (char *s);
+size_t strposb (char *s1, char *s2, ptrdiff_t i);
+size_t strposc (char *s1, char ch, ptrdiff_t i);
+size_t strposcset (char *s1, char *s2, size_t i);
+size_t strposbcset (char *s1, char *s2, size_t i);
+size_t strcipos2 (char *s1, char *s2, size_t i);
+size_t strciposb (char *s1, char *s2, size_t i);
+//int strcontains (char *s1, char *s2);
+int strsubset (char *s1, char *s2);
+int strcommon (char *s1, char *s2);
+size_t strlenv (char *s);
+char *strhex (char * Result, long i, long w);
+char *strbinary (char *Result, long i, size_t w);
+char *strdate (char *Result, char *opts);
+void strword (char *s, char *s2);
+void strword2 (char *s, char *s2);
+void strcomment (char *s, char* bracket);
+void strcompress (char *s, char *chars, int all);
+void strdispose (char **sp);
+void strchange (char** sp, char *);
+char *strcpy_overlap(char *dst, char *src) DEPRECATED;
+
+#endif
diff --git a/include/utils/strlist.h b/include/utils/strlist.h
new file mode 100644
index 0000000000000000000000000000000000000000..bb270a2c23b39d9989fcb1021092fc9c28cde725
--- /dev/null
+++ b/include/utils/strlist.h
@@ -0,0 +1,31 @@
+#ifndef STRLIST_H
+#define STRLIST_H
+
+typedef struct strlist_t
+{
+	struct strlist_t *next;
+	void *value;    /* user-defined */
+	char kind;      /* user-defined */
+	size_t len;     /* for internal use */
+	char *s;
+} strlist_t;
+
+
+void strlist_init (strlist_t **base);
+strlist_t *strlist_find (strlist_t *base, char *s);
+strlist_t *strlist_cifind (strlist_t *base, char *s);
+void strlist_change (strlist_t **base, strlist_t **ptr, char *s);
+void strlist_remove (strlist_t **base, char *s);
+void strlist_delete (strlist_t **base, strlist_t **ptr);
+void strlist_dispose (strlist_t **ptr);
+void strlist_empty (strlist_t **base);
+void strlist_copy (strlist_t **dest, strlist_t *src);
+strlist_t *strlist_add (strlist_t **base, char *s);
+strlist_t *strlist_append (strlist_t **base, char *s);
+strlist_t *strlist_insert (strlist_t **base, char *s);
+
+void strlist_dump (FILE *f, strlist_t *base);
+
+
+#endif
+
diff --git a/include/utils/sysdevs.h b/include/utils/sysdevs.h
new file mode 100644
index 0000000000000000000000000000000000000000..292677fa6c96f0fc19afe48fe2a23c5f9db3983f
--- /dev/null
+++ b/include/utils/sysdevs.h
@@ -0,0 +1,16 @@
+#ifndef SYSDEVS_H
+#define SYSDEVS_H
+
+#include <utils/sysglobals.h>
+
+/** CLOCK ************************************************/
+long sysclock ();
+void sysdate (daterec *thedate);
+void systime (timerec *thetime);
+void setsysdate (daterec thedate);
+void setsystime (timerec thetime);
+
+#endif /*SYSDEVS_H*/
+
+/* End. */
+
diff --git a/psys/include/p2c/sysglobals.h b/include/utils/sysglobals.h
similarity index 91%
rename from psys/include/p2c/sysglobals.h
rename to include/utils/sysglobals.h
index 68df19e8f598e6bb6232187a29117ce92a3bd641..3f9f9422aae332fdfce3c9648e5720c9fbdc9a8a 100644
--- a/psys/include/p2c/sysglobals.h
+++ b/include/utils/sysglobals.h
@@ -1,13 +1,6 @@
 #ifndef SYSGLOBALS_H
 #define SYSGLOBALS_H
 
-
-#ifdef SYSGLOBALS_G
-# define vextern
-#else
-# define vextern extern
-#endif
-
 #define mminint         (-32768L) /*unused/ */
 
 /*MINIMUM SHORT INTEGER VALUE*/
@@ -54,8 +47,6 @@ typedef struct datetimerec {
     timerec time;
 } datetimerec;
 
-#undef vextern
-
 #endif /*SYSGLOBALS_H*/
 
 /* End. */
diff --git a/log/include/wire.h b/include/wire.h
similarity index 100%
rename from log/include/wire.h
rename to include/wire.h
diff --git a/log/lib/actel.gate b/lib/actel.gate
similarity index 100%
rename from log/lib/actel.gate
rename to lib/actel.gate
diff --git a/log/lib/actellog.cnf b/lib/actellog.cnf
similarity index 100%
rename from log/lib/actellog.cnf
rename to lib/actellog.cnf
diff --git a/log/lib/ana.gate b/lib/ana.gate
similarity index 100%
rename from log/lib/ana.gate
rename to lib/ana.gate
diff --git a/log/lib/analog-man.ps b/lib/analog-man.ps
similarity index 100%
rename from log/lib/analog-man.ps
rename to lib/analog-man.ps
diff --git a/log/lib/analog-tr.ps b/lib/analog-tr.ps
similarity index 100%
rename from log/lib/analog-tr.ps
rename to lib/analog-tr.ps
diff --git a/log/lib/analog.cnf b/lib/analog.cnf
similarity index 100%
rename from log/lib/analog.cnf
rename to lib/analog.cnf
diff --git a/log/lib/cheat.text b/lib/cheat.text
similarity index 100%
rename from log/lib/cheat.text
rename to lib/cheat.text
diff --git a/log/lib/diglog.cnf b/lib/diglog.cnf
similarity index 100%
rename from log/lib/diglog.cnf
rename to lib/diglog.cnf
diff --git a/log/lib/fet5model.ps b/lib/fet5model.ps
similarity index 100%
rename from log/lib/fet5model.ps
rename to lib/fet5model.ps
diff --git a/log/lib/fet7model.pdf b/lib/fet7model.pdf
similarity index 100%
rename from log/lib/fet7model.pdf
rename to lib/fet7model.pdf
diff --git a/log/lib/genlog.cnf b/lib/genlog.cnf
similarity index 100%
rename from log/lib/genlog.cnf
rename to lib/genlog.cnf
diff --git a/log/lib/groups.cnf b/lib/groups.cnf
similarity index 100%
rename from log/lib/groups.cnf
rename to lib/groups.cnf
diff --git a/log/lib/ledit_models b/lib/ledit_models
similarity index 100%
rename from log/lib/ledit_models
rename to lib/ledit_models
diff --git a/log/lib/lesson1.lgf b/lib/lesson1.lgf
similarity index 100%
rename from log/lib/lesson1.lgf
rename to lib/lesson1.lgf
diff --git a/log/lib/lesson2.lgf b/lib/lesson2.lgf
similarity index 100%
rename from log/lib/lesson2.lgf
rename to lib/lesson2.lgf
diff --git a/log/lib/lesson3.lgf b/lib/lesson3.lgf
similarity index 100%
rename from log/lib/lesson3.lgf
rename to lib/lesson3.lgf
diff --git a/log/lib/lesson4.lgf b/lib/lesson4.lgf
similarity index 100%
rename from log/lib/lesson4.lgf
rename to lib/lesson4.lgf
diff --git a/log/lib/lesson5.lgf b/lib/lesson5.lgf
similarity index 100%
rename from log/lib/lesson5.lgf
rename to lib/lesson5.lgf
diff --git a/log/lib/librstr.cnf b/lib/librstr.cnf
similarity index 100%
rename from log/lib/librstr.cnf
rename to lib/librstr.cnf
diff --git a/log/lib/linklog b/lib/linklog
similarity index 100%
rename from log/lib/linklog
rename to lib/linklog
diff --git a/log/lib/linkloged b/lib/linkloged
similarity index 100%
rename from log/lib/linkloged
rename to lib/linkloged
diff --git a/log/lib/log.cnf b/lib/log.cnf
similarity index 100%
rename from log/lib/log.cnf
rename to lib/log.cnf
diff --git a/log/lib/log.doc b/lib/log.doc
similarity index 100%
rename from log/lib/log.doc
rename to lib/log.doc
diff --git a/log/lib/log.gate b/lib/log.gate
similarity index 100%
rename from log/lib/log.gate
rename to lib/log.gate
diff --git a/log/lib/log.text b/lib/log.text
similarity index 100%
rename from log/lib/log.text
rename to lib/log.text
diff --git a/log/lib/lognews.text b/lib/lognews.text
similarity index 100%
rename from log/lib/lognews.text
rename to lib/lognews.text
diff --git a/log/lib/logntk.cnf b/lib/logntk.cnf
similarity index 100%
rename from log/lib/logntk.cnf
rename to lib/logntk.cnf
diff --git a/log/lib/logspc.cnf b/lib/logspc.cnf
similarity index 100%
rename from log/lib/logspc.cnf
rename to lib/logspc.cnf
diff --git a/log/lib/logspc.tim b/lib/logspc.tim
similarity index 100%
rename from log/lib/logspc.tim
rename to lib/logspc.tim
diff --git a/log/lib/lplot.cnf b/lib/lplot.cnf
similarity index 100%
rename from log/lib/lplot.cnf
rename to lib/lplot.cnf
diff --git a/log/lib/models.cnf b/lib/models.cnf
similarity index 100%
rename from log/lib/models.cnf
rename to lib/models.cnf
diff --git a/log/lib/mos.cnf b/lib/mos.cnf
similarity index 100%
rename from log/lib/mos.cnf
rename to lib/mos.cnf
diff --git a/log/lib/mos14tb.cnf b/lib/mos14tb.cnf
similarity index 100%
rename from log/lib/mos14tb.cnf
rename to lib/mos14tb.cnf
diff --git a/log/lib/mos26g.cnf b/lib/mos26g.cnf
similarity index 100%
rename from log/lib/mos26g.cnf
rename to lib/mos26g.cnf
diff --git a/log/lib/mos_example.cnf b/lib/mos_example.cnf
similarity index 100%
rename from log/lib/mos_example.cnf
rename to lib/mos_example.cnf
diff --git a/log/lib/mosscn12.cnf b/lib/mosscn12.cnf
similarity index 100%
rename from log/lib/mosscn12.cnf
rename to lib/mosscn12.cnf
diff --git a/lib/.keep b/lib/ntk/.keep
similarity index 100%
rename from lib/.keep
rename to lib/ntk/.keep
diff --git a/log/lib/pens.cnf b/lib/pens.cnf
similarity index 100%
rename from log/lib/pens.cnf
rename to lib/pens.cnf
diff --git a/log/lib/plot.font b/lib/plot.font
similarity index 100%
rename from log/lib/plot.font
rename to lib/plot.font
diff --git a/log/lib/post.spc b/lib/post.spc
similarity index 100%
rename from log/lib/post.spc
rename to lib/post.spc
diff --git a/log/lib/pre.spc b/lib/pre.spc
similarity index 100%
rename from log/lib/pre.spc
rename to lib/pre.spc
diff --git a/log/lib/preamble.ps b/lib/preamble.ps
similarity index 100%
rename from log/lib/preamble.ps
rename to lib/preamble.ps
diff --git a/log/lib/pwl-test.iv b/lib/pwl-test.iv
similarity index 100%
rename from log/lib/pwl-test.iv
rename to lib/pwl-test.iv
diff --git a/log/lib/pwl-test.lgf b/lib/pwl-test.lgf
similarity index 100%
rename from log/lib/pwl-test.lgf
rename to lib/pwl-test.lgf
diff --git a/log/lib/spcfet5.lgf b/lib/spcfet5.lgf
similarity index 100%
rename from log/lib/spcfet5.lgf
rename to lib/spcfet5.lgf
diff --git a/log/lib/spctest.lgf b/lib/spctest.lgf
similarity index 100%
rename from log/lib/spctest.lgf
rename to lib/spctest.lgf
diff --git a/log/lib/vlsi.cnf b/lib/vlsi.cnf
similarity index 100%
rename from log/lib/vlsi.cnf
rename to lib/vlsi.cnf
diff --git a/log/COPYING b/log/COPYING
deleted file mode 100644
index 9a170375811150e8f01ab7b88513aeeee5e527d1..0000000000000000000000000000000000000000
--- a/log/COPYING
+++ /dev/null
@@ -1,249 +0,0 @@
-
-		    GNU GENERAL PUBLIC LICENSE
-		     Version 1, February 1989
-
- Copyright (C) 1989 Free Software Foundation, Inc.
-                    675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-			    Preamble
-
-  The license agreements of most software companies try to keep users
-at the mercy of those companies.  By contrast, our General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users.  The
-General Public License applies to the Free Software Foundation's
-software and to any other program whose authors commit to using it.
-You can use it for your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Specifically, the General Public License is designed to make
-sure that you have the freedom to give away or sell copies of free
-software, that you receive source code or can get it if you want it,
-that you can change the software or use pieces of it in new free
-programs; and that you know you can do these things.
-
-  To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
-  For example, if you distribute copies of a such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have.  You must make sure that they, too, receive or can get the
-source code.  And you must tell them their rights.
-
-  We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
-  Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software.  If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-
-		    GNU GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any program or other work which
-contains a notice placed by the copyright holder saying it may be
-distributed under the terms of this General Public License.  The
-"Program", below, refers to any such program or work, and a "work based
-on the Program" means either the Program or any work containing the
-Program or a portion of it, either verbatim or with modifications.  Each
-licensee is addressed as "you".
-
-  1. You may copy and distribute verbatim copies of the Program's source
-code as you receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice and
-disclaimer of warranty; keep intact all the notices that refer to this
-General Public License and to the absence of any warranty; and give any
-other recipients of the Program a copy of this General Public License
-along with the Program.  You may charge a fee for the physical act of
-transferring a copy.
-
-  2. You may modify your copy or copies of the Program or any portion of
-it, and copy and distribute such modifications under the terms of Paragraph
-1 above, provided that you also do the following:
-
-    a) cause the modified files to carry prominent notices stating that
-    you changed the files and the date of any change; and
-
-    b) cause the whole of any work that you distribute or publish, that
-    in whole or in part contains the Program or any part thereof, either
-    with or without modifications, to be licensed at no charge to all
-    third parties under the terms of this General Public License (except
-    that you may choose to grant warranty protection to some or all
-    third parties, at your option).
-
-    c) If the modified program normally reads commands interactively when
-    run, you must cause it, when started running for such interactive use
-    in the simplest and most usual way, to print or display an
-    announcement including an appropriate copyright notice and a notice
-    that there is no warranty (or else, saying that you provide a
-    warranty) and that users may redistribute the program under these
-    conditions, and telling the user how to view a copy of this General
-    Public License.
-
-    d) You may charge a fee for the physical act of transferring a
-    copy, and you may at your option offer warranty protection in
-    exchange for a fee.
-
-Mere aggregation of another independent work with the Program (or its
-derivative) on a volume of a storage or distribution medium does not bring
-the other work under the scope of these terms.
-
-  3. You may copy and distribute the Program (or a portion or derivative of
-it, under Paragraph 2) in object code or executable form under the terms of
-Paragraphs 1 and 2 above provided that you also do one of the following:
-
-    a) accompany it with the complete corresponding machine-readable
-    source code, which must be distributed under the terms of
-    Paragraphs 1 and 2 above; or,
-
-    b) accompany it with a written offer, valid for at least three
-    years, to give any third party free (except for a nominal charge
-    for the cost of distribution) a complete machine-readable copy of the
-    corresponding source code, to be distributed under the terms of
-    Paragraphs 1 and 2 above; or,
-
-    c) accompany it with the information you received as to where the
-    corresponding source code may be obtained.  (This alternative is
-    allowed only for noncommercial distribution and only if you
-    received the program in object code or executable form alone.)
-
-Source code for a work means the preferred form of the work for making
-modifications to it.  For an executable file, complete source code means
-all the source code for all modules it contains; but, as a special
-exception, it need not include source code for modules which are standard
-libraries that accompany the operating system on which the executable
-file runs, or for standard header files or definitions files that
-accompany that operating system.
-
-  4. You may not copy, modify, sublicense, distribute or transfer the
-Program except as expressly provided under this General Public License.
-Any attempt otherwise to copy, modify, sublicense, distribute or transfer
-the Program is void, and will automatically terminate your rights to use
-the Program under this License.  However, parties who have received
-copies, or rights to use copies, from you under this General Public
-License will not have their licenses terminated so long as such parties
-remain in full compliance.
-
-  5. By copying, distributing or modifying the Program (or any work based
-on the Program) you indicate your acceptance of this license to do so,
-and all its terms and conditions.
-
-  6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the original
-licensor to copy, distribute or modify the Program subject to these
-terms and conditions.  You may not impose any further restrictions on the
-recipients' exercise of the rights granted herein.
-
-  7. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Program
-specifies a version number of the license which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation.  If the Program does not specify a version number of
-the license, you may choose any version ever published by the Free Software
-Foundation.
-
-  8. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission.  For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this.  Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
-			    NO WARRANTY
-
-  9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
-  10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
-		     END OF TERMS AND CONDITIONS
-
-	Appendix: How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to humanity, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these
-terms.
-
-  To do so, attach the following notices to the program.  It is safest to
-attach them to the start of each source file to most effectively convey
-the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) 19yy  <name of author>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 1, or (at your option)
-    any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
-    Gnomovision version 69, Copyright (C) 19xx name of author
-    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the
-appropriate parts of the General Public License.  Of course, the
-commands you use may be called something other than `show w' and `show
-c'; they could even be mouse-clicks or menu items--whatever suits your
-program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary.  Here a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  program `Gnomovision' (a program to direct compilers to make passes
-  at assemblers) written by James Hacker.
-
-  <signature of Ty Coon>, 1 April 1989
-  Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/log/Makefile b/log/Makefile
deleted file mode 100644
index 47abcda6f3263b43ba7059958bb3befd689863fa..0000000000000000000000000000000000000000
--- a/log/Makefile
+++ /dev/null
@@ -1,175 +0,0 @@
-
-#  "LOG", the circuit editing and simulation system, 5.66
-#  "DigLOG", the digital simulator for LOG.
-#  Copyright (C) 1985, 1990 David Gillespie.
-#  Author's address: daveg@synaptics.edu
-
-#  "AnaLOG", the analog simulator for LOG, 5.66
-#  Copyright (C) 1985, 1990 John Lazzaro.
-#  Author's address: lazzaro@cs.berkeley.edu;
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation (any version).
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program; see the file COPYING.  If not, write to
-# the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-CD = cd
-
-LOGINC = include
-TARGET_DIR = target
-SRC_DIR = src
-TOOLS_DIR = tools
-
-LOGLIBDIR = `$(CD) lib; pwd`
-LIBDIR = `$(CD) ../lib; pwd`
-
-LOCINC = ../psys/include
-
-XINCLUDEDIR = .
-
-BINDIR = ../bin
-LIBP2C = ../psys/src/libp2c.a
-
-LIBX11 = -lX11
-
-OTHERLIBS= -lm
-
-CHIPMUNKCC = gcc -O3
-
-CC = $(CHIPMUNKCC)
-
-CHIPMUNKFLAGS = $(ARCH_OPT)
-
-STDC = gnu11
-
-CFLAGS = $(CHIPMUNKFLAGS) -I$(LOGINC) -I$(LOCINC) -I$(XINCLUDEDIR)	\
-	 -DLOGLIB="\"$(LOGLIBDIR)\"" -DF_OK=0 -std=$(STDC) -g -Wall -Wextra
-
-DIGOBJ = $(TARGET_DIR)/logsim.o $(TARGET_DIR)/logdig.o		\
-         $(TARGET_DIR)/logsimasm.o $(TARGET_DIR)/logsimed.o	\
-         $(TARGET_DIR)/diggates.o $(TARGET_DIR)/loghier.o	\
-         $(TARGET_DIR)/logsimh.o $(TARGET_DIR)/swap.o
-ANAOBJ = $(TARGET_DIR)/ana/globals.o $(TARGET_DIR)/ana/nsolver.o	\
-         $(TARGET_DIR)/ana/main.o $(TARGET_DIR)/ana/inter.o		\
-         $(TARGET_DIR)/ana/numbers.o $(TARGET_DIR)/ana/mmeter.o		\
-         $(TARGET_DIR)/ana/iscope.o $(TARGET_DIR)/ana/devtechp.o	\
-         $(TARGET_DIR)/ana/vdiff.o $(TARGET_DIR)/ana/vswitch.o		\
-         $(TARGET_DIR)/ana/stairs.o $(TARGET_DIR)/ana/runspec.o		\
-         $(TARGET_DIR)/ana/idiff.o $(TARGET_DIR)/ana/iswitch1.o		\
-         $(TARGET_DIR)/ana/iswitch2.o $(TARGET_DIR)/ana/devtechn.o	\
-         $(TARGET_DIR)/ana/resfloat.o $(TARGET_DIR)/ana/capfloat.o	\
-         $(TARGET_DIR)/ana/nfet4.o $(TARGET_DIR)/ana/pfet4.o		\
-         $(TARGET_DIR)/ana/nfet5.o $(TARGET_DIR)/ana/pfet5.o		\
-         $(TARGET_DIR)/ana/pfet6.o $(TARGET_DIR)/ana/pspc1.o		\
-         $(TARGET_DIR)/ana/nspc1.o $(TARGET_DIR)/ana/nfet7t.o		\
-         $(TARGET_DIR)/ana/nfet7f.o $(TARGET_DIR)/ana/pfet7t.o		\
-         $(TARGET_DIR)/ana/pfet7f.o $(TARGET_DIR)/ana/thermal.o		\
-         $(TARGET_DIR)/ana/tc.o $(TARGET_DIR)/ana/moscap.o		\
-         $(TARGET_DIR)/ana/ganglion.o $(TARGET_DIR)/ana/hres.o		\
-         $(TARGET_DIR)/ana/physical.o $(TARGET_DIR)/ana/npn1.o		\
-         $(TARGET_DIR)/ana/pnp1.o $(TARGET_DIR)/ana/npn2.o		\
-         $(TARGET_DIR)/ana/pnp2.o $(TARGET_DIR)/ana/diode1.o		\
-         $(TARGET_DIR)/ana/pwl.o $(TARGET_DIR)/ana/rtd.o
-
-SIMOBJ = $(TARGET_DIR)/logcom.o $(DIGOBJ) $(ANAOBJ)
-TOOLOBJ = $(SIMOBJ) $(TARGET_DIR)/logspc.o $(TARGET_DIR)/logntk.o	\
-	  $(TARGET_DIR)/label.o $(TARGET_DIR)/wire.o			\
-	  $(TARGET_DIR)/page.o $(TARGET_DIR)/gate.o			\
-	  $(TARGET_DIR)/screen.o $(TARGET_DIR)/node.o			\
-	  $(TARGET_DIR)/tool.o $(TARGET_DIR)/utils.o		\
-	  $(TARGET_DIR)/pagewriter.o $(TARGET_DIR)/pagereader.o
-
-
-$(TARGET_DIR)/ana/%.o: $(SRC_DIR)/ana/%.c
-$(TARGET_DIR)/%.o: $(SRC_DIR)/%.c
-	@mkdir -p $(@D)
-	$(CC) -c $(CFLAGS) $< -o $@
-
-
-install: all
-	cp $(TARGET_DIR)/log $(BINDIR)/diglog
-	-rm -f $(BINDIR)/analog
-	-(cd $(BINDIR); ln -s diglog analog)
-	cp $(TARGET_DIR)/loged $(BINDIR)/loged
-
-clean:
-	rm -rf $(TARGET_DIR)/*
-
-all: main
-
-main: $(TARGET_DIR)/log $(TARGET_DIR)/loged
-
-
-LOGOBJ = $(TARGET_DIR)/log.o $(TOOLOBJ) $(TARGET_DIR)/logstuff.o $(TARGET_DIR)/logdef.o
-
-
-$(TARGET_DIR)/log: $(LOGOBJ) $(TARGET_DIR)/tooldir.o $(LIBP2C)
-	$(CC) $(CFLAGS) $(TARGET_DIR)/tooldir.o $(LOGOBJ) $(LIBP2C) $(LIBX11)  \
-	$(OTHERLIBS) -o $(TARGET_DIR)/log
-
-
-LOGEDOBJ = $(TARGET_DIR)/loged.o $(TARGET_DIR)/simdir.o $(SIMOBJ) $(TARGET_DIR)/logstuff.o
-
-$(TARGET_DIR)/loged: $(LOGEDOBJ) $(TARGET_DIR)/simdir.o $(LIBP2C)
-	$(CC) $(CFLAGS) $(LOGEDOBJ) $(LIBP2C) $(LIBX11) $(OTHERLIBS) -o $(TARGET_DIR)/loged
-
-$(TARGET_DIR)/tooldir.o: $(SRC_DIR)/tooldir.c
-
-$(SRC_DIR)/tooldir.c: $(TOOLOBJ)
-	chmod +x $(TOOLS_DIR)/munch
-	$(TOOLS_DIR)/munch 'Log_[a-zA-Z0-9_]*' $(TOOLOBJ) > $(SRC_DIR)/tooldir.c
-
-$(TARGET_DIR)/simdir.o: $(SRC_DIR)/simdir.c
-
-$(SRC_DIR)/simdir.c: $(SIMOBJ)
-	chmod +x $(TOOLS_DIR)/munch
-	$(TOOLS_DIR)/munch 'Log_[0-9]*_proc' $(SIMOBJ) > $(SRC_DIR)/simdir.c
-
-
-## The following part of the Makefile is for making a tar file of the
-## original parts of the log distribution. Most users have no need for it.
-
-
-VERSION = 5.66
-
-dist: distrib
-distrib:
-	-rm -rf dist
-	mkdir dist
-	mkdir dist/src
-	mkdir dist/src/ana
-	cp log.cnf log.gate COPYING LNOTES dist/src
-	cp munch.default  dist/src/munch
-	cp simdir.os2 tooldir.os2 dist/src
-	sed -e "s;5.66;$(VERSION);" Makefile > dist/src/Makefile
-	sed -e "s;5.66;$(VERSION);" ana/Makefile > dist/src/ana/Makefile
-	sed -e "s;5.66;$(VERSION);" Makefile.os2 > dist/src/Makefile.os2
-	sed -e "s;5.66;$(VERSION);" ana/Makefile.os2 > dist/src/ana/Makefile.os2
-	sed -e "s;5.66;$(VERSION);" dist.INSTALL > dist/README
-	cp *.c *.h dist/src
-	sed -e "s;5.66;$(VERSION);"  logdef.h > dist/src/logdef.h
-	cp ana/*.c ana/*.h dist/src/ana
-	cp -r $(LOGLIBDIR) dist/lib
-	echo >dist/lib/stupid~
-	-rm -f dist/lib/*~ dist/lib/*.ogte
-	sed -e "s;5.66;$(VERSION);" ../lib/log.doc > dist/lib/log.doc
-
-
-tardist:
-	-rm -rf logdist
-	mkdir logdist
-	mv dist logdist/log
-	tar cvf log.tar -C logdist log
-	mv logdist/log dist
-	-rm -f log.tar.gz
-	gzip log.tar
-
-create: dist tardist
diff --git a/log/include/logntk.h b/log/include/logntk.h
deleted file mode 100644
index 7ff271f9d0bba52a0724dd6818f6882cea6d0b92..0000000000000000000000000000000000000000
--- a/log/include/logntk.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef LOGNTK_H
-#define LOGNTK_H
-
-#include "logdef.h"
-#include "loghier.h"
-#include <p2c/newasm.h>
-#include <p2c/newkbd.h>
-#include <p2c/newci.h>
-#include <p2c/newcrt.h>
-#include <p2c/mylib.h>
-#include <p2c/regex.h>
-
-extern void Log_logntk_proc (log_action_t *act);
-
-#endif /*LOGNTK_H*/
-
-/* End. */
diff --git a/log/include/logspc.h b/log/include/logspc.h
deleted file mode 100644
index 09bff6ff733a6f5b80ef0c7deb0062a03aadd429..0000000000000000000000000000000000000000
--- a/log/include/logspc.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#ifndef LOGSPC_H
-#define LOGSPC_H
-
-#include "logdef.h"
-#include "loghier.h"
-#include <p2c/newasm.h>
-#include <p2c/newkbd.h>
-#include <p2c/newci.h>
-#include <p2c/newcrt.h>
-#include <p2c/mylib.h>
-#include <p2c/regex.h>
-
-extern void Log_logspc_proc (log_action_t *act);
-
-#endif /*LOGSPC_H*/
-
-/* End. */
diff --git a/log/lib/ntk/.keep b/log/lib/ntk/.keep
deleted file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
diff --git a/psys/include/p2c/filepack.h b/psys/include/p2c/filepack.h
deleted file mode 100644
index e3f750347ad25f2cfa50bbe80a5e0cfcec826f23..0000000000000000000000000000000000000000
--- a/psys/include/p2c/filepack.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef FILEPACK_H
-#define FILEPACK_H
-
-#include <p2c/sysglobals.h>
-
-extern void fp_change (char *filename1, char *filename2);
-extern void fp_remove (char *filename);
-extern int fp_getwd (char *path, char *rootname);
-
-#endif /*FILEPACK_H*/
-
-/* End. */
diff --git a/psys/include/p2c/misc.h b/psys/include/p2c/misc.h
deleted file mode 100644
index d71d7b40f13a27875222ed30ab50c6c5c4aadaab..0000000000000000000000000000000000000000
--- a/psys/include/p2c/misc.h
+++ /dev/null
@@ -1,22 +0,0 @@
-#ifndef MISC_H
-#define MISC_H
-
-/*homeless orphans*/
-#include <p2c/sysglobals.h>
-
-#ifdef MISC_G
-# define vextern
-#else
-# define vextern extern
-#endif
-
-/* idle character -- 3.0 bug jws 3/20/84 */
-extern void misc_getioerrmsg (char *s, long lastior);
-extern char *tilde_expand  (char *s);
-
-#undef vextern
-
-#endif /*MISC_H*/
-
-/* End. */
-
diff --git a/psys/include/p2c/mylib.h b/psys/include/p2c/mylib.h
deleted file mode 100644
index 358a4cdfe0335ced1184d5553c2590be0486381f..0000000000000000000000000000000000000000
--- a/psys/include/p2c/mylib.h
+++ /dev/null
@@ -1,183 +0,0 @@
-#ifndef MYLIB_H
-#define MYLIB_H
-
-#include <X11/Xlib.h>
-
-#ifdef MYLIB_G
-# define vextern
-#else
-# define vextern extern
-#endif
-
-
-typedef uchar m_colorarray[17];
-
-typedef uchar m_vcolorarray[1000001L];
-
-typedef struct m_chpicrec {
-    int xsize : 8, ysize : 8, xoff : 8, yoff : 8;
-    unsigned xdim : 8, ydim : 8, width : 8, height : 8;
-    long pic[32];
-} m_chpicrec;
-
-typedef struct m_cchpicrec {
-    int xsize : 8, ysize : 8, xoff : 8, yoff : 8;
-    unsigned xdim : 8, ydim : 8, width : 8, height : 8;
-    uchar pic[32][32];
-} m_cchpicrec;
-
-typedef struct m_tablet_info {
-    long x, y;
-    short phx, phy, fill1;
-    int ax : 8, ay : 8;
-    unsigned menu : 8, depressed : 1, near_ : 1, dn : 1, up : 1, off : 1, clip : 1,
-             moving : 1, inalpha : 1;
-} m_tablet_info;
-
-
-
-#define m_black         0
-#define m_red           1
-#define m_green         2
-#define m_yellow        3
-#define m_blue          4
-#define m_purple        5
-#define m_cyan          6
-#define m_white         7
-#define m_xblack        16
-#define m_xred          17
-#define m_xgreen        18
-#define m_xyellow       19
-#define m_xblue         20
-#define m_xpurple       21
-#define m_xcyan         22
-#define m_xwhite        23
-#define m_normal        0
-#define m_xor           16
-#define m_over          32
-#define m_mask          48
-#define m_add           64
-#define m_sub           80
-#define m_user          96
-
-#define m_scan          0xf8f8L
-#define m_erase         0xf9f9L
-#define m_hitdet        0xfafaL
-#define m_chg           0xfbfbL
-#define m_chgtab        0xfcfcL
-#define m_pat           0xfdfdL
-#define m_fastu         0xfefeL
-#define m_trans         0xffffL
-
-#define m_mode          256
-#define m_rule_erase    0
-#define m_rule_and      1
-#define m_rule_normal   3
-#define m_rule_mask     4
-#define m_rule_trans    5
-#define m_rule_xor      6
-#define m_rule_over     7
-#define m_rule_not      10
-#define m_rule_inv      12
-#define m_rule_ones     15
-#define m_pie           1
-#define m_chord         2
-#define m_extarc        3
-
-
-
-vextern long m_hitcount, m_across, m_down;
-vextern long m_maxcolor;
-vextern Display *m_display;
-vextern Window m_window;
-vextern int m_initialized;
-vextern int BlackAndWhite;
-vextern int screennum;
-
-#define ColorsInSet           16
-#define ColorSets              4
-extern XColor m_colors[ColorSets+1][ColorsInSet];
-
-/* Added X display name support.  stafford 7/17/91 */
-extern void m_set_display_name(char* display_name);
-extern char m_display_name[];
-extern int m_autoraise;
-
-extern void m_init_screen ();
-extern void m_init_colors ();
-extern void m_init_pen (int);
-extern void m_init_graphics ();
-extern void m_clear ();
-extern void m_clip (int, int, int, int);
-extern void m_noclip ();
-extern void m_unclip();	
-extern void m_transform (int, int, int, int, int, int, int);
-extern void m_upside_down ();
-extern void m_rotscale (double, double, int, int);
-extern void m_rotscaled (double, double, int, int);
-extern void m_notransform ();
-extern void m_untransform();
-extern void m_cursor (int, int);
-extern void m_nocursor ();
-extern void m_choosecursor (int);
-extern void m_color (int);
-extern void m_colormode (int c);
-extern long m_curcolor ();
-extern long m_curcolormode ();
-extern void m_setcolor();
-extern void m_seecolor (int, int *, int *, int *);
-extern void m_setcolors (m_colorarray, m_colorarray, m_colorarray);
-extern void m_seecolors (m_colorarray, m_colorarray, m_colorarray);
-extern void m_vsetcolors (int, int, m_vcolorarray, m_vcolorarray, m_vcolorarray);
-extern void m_vseecolors (int, int, m_vcolorarray, m_vcolorarray, m_vcolorarray);
-extern void m_choosecolors (int);
-extern void m_linestyle (int);
-extern void m_setlinestyle (int, int);
-extern void m_move (int, int);
-extern void m_move2 (int, int);
-extern void m_draw (int, int);
-extern void m_drawrel (int, int);
-extern void m_drawline (int, int, int, int);
-extern void m_drawrect (int, int, int, int);
-extern void m_fillrect (int, int, int, int);
-extern void m_grid (int, int, int, int, int, int, int, int);
-extern void m_drawpoint (int, int);
-extern void m_circle (int, int, int);
-extern void m_ellipse (int, int, int, int, int);
-extern void m_drawarc (long, long, long, long, double, double, double, long);
-extern void m_fillarc (long, long, long, long, double, double, double, long);
-extern void m_roundrect (int, int, int, int, int, int, int);
-extern void m_bezier (int, int, int, int, int, int, int, int);
-extern void m_bezier2 (int, int, int, int, int, int, int, int, int);
-extern void m_cbezier (int, int, int, int, int, int, int, int, int);
-extern void m_polycurve (double, double, double, double, double, double, double, double, double, double, double, double);
-extern void m_drawpoly (int, int [], int []);
-extern void m_fillpoly (int, int [], int []);
-extern void m_drawstr (int, int, char *, char *);
-extern void m_centerstr (int, int, char *, char *);
-extern void m_rightstr (int, int, char *, char *);
-extern long m_strwidth (char *, char *);
-extern void m_setfont();
-extern void m_seefont();
-extern void m_graphics_on();
-extern void m_alpha_on();
-
-#define m_graphics_off()
-#define m_alpha_off()
-
-extern void m_readpen();
-extern void m_trackpen();
-extern void m_waitpen();
-extern void m_clipxy();
-extern int m_pollkbd();
-extern uchar m_inkey();
-extern uchar m_inkeyn();
-extern uchar m_testkey();
-
-
-#undef vextern
-
-#endif /*MYLIB_H*/
-
-/* End. */
-
diff --git a/psys/include/p2c/newasm.h b/psys/include/p2c/newasm.h
deleted file mode 100644
index 9248edd43a18c75ddab5cb5569ce7303a46d8f22..0000000000000000000000000000000000000000
--- a/psys/include/p2c/newasm.h
+++ /dev/null
@@ -1,28 +0,0 @@
-#ifndef NEWASM_H
-#define NEWASM_H
-
-typedef void* na_long;
-
-extern void na_exch (long *s, long *d, long size);
-
-extern long na_log2 (long n);
-extern long na_po2 (long n);
-
-extern long na_bfextu (long *v, long offset, long size);
-
-extern long na_bfcount (long *v, long offset, long size);
-extern long na_setcard (long *s);
-
-extern long P_imax2 (long a, long b);
-extern long P_imin2 (long a, long b);
-extern void P_iswap2 (long *a, long *b);
-extern long P_ibound (long min, long i, long max);
-extern int P_ibetween (long min, long i, long max);
-extern int P_ibetweenm (long min, long i, long max, long margin);
-
-extern void* na_rtosr (double r);
-extern double na_srtor (void* sr);
-
-#endif /*NEWASM_H*/
-
-/* End. */
diff --git a/psys/include/p2c/newci.h b/psys/include/p2c/newci.h
deleted file mode 100644
index f6a18aaa4c63257e9d3d6e982421cfd141d60a88..0000000000000000000000000000000000000000
--- a/psys/include/p2c/newci.h
+++ /dev/null
@@ -1,45 +0,0 @@
-#ifndef NEWCI_H
-#define NEWCI_H
-
-
-#ifdef NEWCI_G
-# define vextern
-#else
-# define vextern extern
-#endif
-
-typedef struct newci_parserec {
-	char switch_[4];
-	size_t used;
-	char kind; /* kind of union below */
-	union {
-		long i;
-		double r;
-		char *s;
-	} UU;
-} newci_parserec;
-
-extern int P_argc;
-extern char **P_argv;
-
-extern void newci_parseswitch (newci_parserec *tab, size_t size, char *bad);
-extern void newci_eatargument ();
-extern void newci_fixfname (char *s, char *ext, char *home);
-extern void newci_forcefname (char *s, char *ext, char *home);
-extern void newci_shellescape (char *args);
-extern void newci_fullshellescape (char *args, char *opts);
-extern void newci_fulleditescape (char *fn, char *opts, long ln, long pos);
-extern void newci_nullrecover ();
-
-extern void newci_inputmap ();
-extern void newci_inputunmap ();
-extern void newci_inputstring (char *s);
-extern long timers_sysclock ();
-extern long newci_fullseconds ();
-
-#undef vextern
-
-#endif /*NEWCI_H*/
-
-/* End. */
-
diff --git a/psys/include/p2c/newcrt.h b/psys/include/p2c/newcrt.h
deleted file mode 100644
index 09ceebe8c8817395e78b430a862c7f6646e06656..0000000000000000000000000000000000000000
--- a/psys/include/p2c/newcrt.h
+++ /dev/null
@@ -1,258 +0,0 @@
-#ifndef NEWCRT_H
-#define NEWCRT_H
-#include <X11/Xlib.h>
-
-
-#ifdef NEWCRT_G
-# define vextern
-#else
-# define vextern extern
-#endif
-
-
-
-/* Caged_date="r      nc_revision='V1.01: $X';" */
-#define nc_revision     "V1.01: Dec 17, 1988 11:00 pm"
-
-
-vextern short XPOS, YPOS;
-
-/* Window stuff */
-/* Maybe use this info?? */
-/* Graphics window */
-/* Clip region */
-/* Offsets to add for gLine */
-/* Saved values of xpos, ypos */
-/*Number of bytes needed to save window*/
-/*NIL or pointer to save area*/
-
-typedef struct nc_windowRec {
-    short top, height, left, width;
-    long area;
-    short font, gcolor, gtop, gheight, gleft, gwidth, gminx, gmaxx, gminy,
-	  gmaxy, goffx, goffy, savex, savey, saveHigh;
-    long saveSize;
-    void* *saveArea;
-} nc_windowRec;
-
-
-
-/* newCrt-4  */
-/* newCrt-8  */
-/* newCrt-12 */
-/* newCrt-16 */
-/* newCrt-20 */
-/* Character re-mapping stuff */
-
-typedef short nc_maparray[256];
-
-
-
-/* newCrt-22  NOT USED ANY MORE */
-/* newCrt-26  NOT USED ANY MORE */
-/* newCrt-28 */
-/* newCrt-30 */
-/* Font information */
-#define nc_maxFonts     4
-
-
-
-typedef struct nc_fontRec {
-    short foffset, fwidth, fheight;
-} nc_fontRec;
-
-
-
-/*nc_windows : array[0..nc_maxWindows] of nc_windowRec;*/
-/* Exciting colors */
-#define nc_green        0
-#define nc_yellow       4096
-#define nc_black        8192
-#define nc_red          12288
-#define nc_cyan         16384
-#define nc_white        20480
-#define nc_blue         24576
-#define nc_purple       28672
-
-/* Exciting attributes */
-#define nc_inv          256
-#define nc_blink        512
-#define nc_under        1024
-#define nc_half         2048
-
-/* Exciting displays */
-#define nc_g26          0
-#define nc_g36          2
-#define nc_g36c         4
-#define nc_g300         6
-
-/* #define nc_fontwidth 8 */
-#define nc_fontwidth 8 
-#define nc_fontheight 13
-
-
-/* Command translation */
-
-typedef char nc_commandArray[256];
-
-
-
-/* Things to deal with graphics junk left on screen */
-/* Information about graphics VS alpha screen stuff */
-/* left edge of main window */
-/* top of main window */
-/* pixels/character in X */
-/* pixels/character in Y */
-/* real width of hardware */
-/* real height of hardware */
-/* number of graphics colors */
-/* number of available graphics colors */
-
-typedef union nc_crtword {
-    struct {
-      char h, c;
-    } U1;
-    short i;
-} nc_crtword;
-
-typedef nc_crtword nc_scrtype[];
-
-
-
-/* call nc_refreshXY, etc after changing! */
-/* New, improved Colors to eliminate Mylib conflicts. */
-
-typedef uchar nc_colorarray[3][256];
-
-
-#ifndef NEWCRT_G
-extern nc_windowRec *nc_curWindow;
-extern nc_windowRec *nc_mainWindow, *nc_lastLineWindow, *nc_statusWindow,
-                    *nc_defaultWindow;
-#endif
-vextern int nc_text_in_window;
-vextern Window nc_window;
-vextern int nc_initialized;
-vextern GC nc_gc;
-vextern short nc_highlight, nc_defaultHighlight;
-vextern nc_windowRec *nc_tempWindow;
-vextern nc_fontRec nc_fonts[nc_maxFonts + 1];
-vextern char *nc_commands;
-vextern _PROCEDURE nc_startAlphaHook, nc_endAlphaHook;
-vextern struct {
-    short left, top, xincr, yincr, width, height, colors, gColors;
-} nc_g;
-vextern nc_crtword *nc_screen;
-vextern uchar (*nc_colors)[256];
-
-
-
-/* Simulation routines.  Should GO AWAY. */
-extern void nc_scrollDown ();
-extern void nc_scrollUp ();
-extern void nc_setWindow (int s, int l);
-extern void nc_revCheck (char *rev);
-extern void nc_setbeep (int b);
-extern short nc_getNumPlanes ();
-extern short nc_getAlphaPlanes ();
-extern void nc_setAlphaPlanes (int num);
-extern short nc_getGraphicsPlanes ();
-extern void nc_setGraphicsPlanes (int num);
-extern int nc_alphashared ();
-extern void nc_sharealpha (int b);
-extern void nc_setAlpha (int on);
-extern void nc_setGraphics (int on);
-extern short nc_getPlanes ();
-extern void nc_setPlanes (int mask);
-extern void nc_putChar (int x, int y, int c);
-extern void nc_putChars (int x, int y, int len, char *c);
-extern void nc_putStr (int x, int y, char *s);
-extern void nc_writeStr (int x, int y, char *s);
-extern char nc_getChar (int x, int y);
-extern void nc_getChars (int x, int y, int len, char *c);
-extern void nc_getStr (int x, int y, char *s);
-extern short nc_getHighlight (int x, int y);
-extern void nc_setHighlight (int high);
-extern void nc_writeHighlight (int x, int y, int len, int newhigh);
-extern void nc_orHighlight (int x, int y, int len, int newhigh);
-extern void nc_andnotHighlight (int x, int y, int len, int newhigh);
-extern void nc_putWord (int x, int y, int w);
-extern void nc_putWords (int x, int y, int len, short *w);
-extern short nc_getWord (int x, int y);
-extern void nc_getWords (int x, int y, int len, short *w);
-extern void nc_makeWindow (nc_windowRec *w, int ptop, int pheight,
-			      int pleft, int pwidth);
-extern void nc_setWindow_ (nc_windowRec *w);
-extern void nc_saveWindow ();
-extern void nc_restoreWindow ();
-extern void nc_exchangeWindow ();
-extern void nc_refreshON ();
-extern void nc_refreshOFF ();
-extern void nc_refreshXY (int x, int y, int dx, int dy);
-extern void nc_refreshWindow ();
-extern void nc_refreshScreenXY (int x, int y, int dx, int dy);
-extern void nc_refreshScreen ();
-extern short nc_gType ();
-extern void nc_aCMap (int col, int r, int g, int b);
-extern void nc_defaCMap ();
-extern void nc_gCMap (int col, int r, int g, int b);
-extern void nc_defgCMap ();
-extern void nc_gColor (int col);
-extern void nc_gLine (int x1, int y1, int x2, int y2);
-extern void nc_gFillRect (int x1, int y1, int x2, int y2);
-extern void nc_gBlit (int repl_rule, int dox, int doy, int sox, int soy,
-			 int width, int height);
-extern void nc_gClear ();
-extern void nc_gClipToWindow (int x1, int y1, int x2, int y2);
-extern void nc_gClipToHardware (int x1, int y1, int x2, int y2);
-extern void nc_clearXY (int x, int y, int dx, int dy);
-extern void nc_clear ();
-extern void nc_scrollUp_ ();
-extern void nc_scrollDown_ ();
-extern void nc_scrollLeft ();
-extern void nc_scrollRight ();
-extern void nc_scrollXY (int dx, int dy);
-extern void nc_insChar (int x, int y, int numChars);
-extern void nc_insLine (int y, int numLines);
-extern void nc_getXY (long *x, long *y);
-extern void nc_setXY (int x, int y);
-extern void nc_gotoXY (int x, int y);
-extern void nc_cursXY (int x, int y);
-extern void nc_cursorOn ();
-extern void nc_cursorOff ();
-extern void nc_nothing ();
-extern void nc_unInit ();
-extern void nc_init ();
-extern void nc_setDevice (long newDevice);
-
-char *nc_fgets (char *s, int n, FILE *stream);
-char *nc_gets (char *s);
-
-/* added for C99 clang compatibility */
-
-void nc_putc (uchar c, FILE * outfile);
-void nc_putchar (uchar c);
-void nc_puts (char * s);
-void nc_fputs (char * s, FILE *outfile);
-
-void nc_printf (char * fmt, ...);
-void nc_fprintf (FILE * outfile, char * fmt, ...);
-
-#define printf nc_printf 
-#define fprintf nc_fprintf 
-#define puts nc_puts
-#undef putchar
-#define putchar nc_putchar
-#undef putc
-#define putc nc_putc
-#define fputs nc_fputs
-#define gets nc_gets
-#define fgets nc_fgets
-
-
-#undef vextern
-
-#endif /*NEWCRT_H*/
-
-/* End. */
-
diff --git a/psys/include/p2c/regex.h b/psys/include/p2c/regex.h
deleted file mode 100644
index e14c612ad82dd153c80ccb4c6e28b41edab96120..0000000000000000000000000000000000000000
--- a/psys/include/p2c/regex.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef REGEX_H
-#define REGEX_H
-
-
-#include <p2c/newasm.h>
-
-
-#define re_defchars     "\\[]^-*?+$.|~(){}:=<>"
-#define re_shellchars   "\\[]^-    ?       *  "
-
-extern void re_compile (char *ex, char *rex, char *chars);
-extern void re_cicompile (char *ex, char *rex, char *chars);
-extern void re_dump (char *rex);
-extern void re_search (char *s, char *rex, size_t *pos, size_t *last, size_t dir);
-extern int re_compare (char *s, char *rex);
-extern void re_replace (char *s, char *rex, char *rpl, size_t *pos,
-			   size_t *last);
-extern int re_matchstr (char *s, char *pat);
-extern int re_matchsubstr (char *s, char *pat, size_t start, size_t *last);
-extern void re_grepl (char *s, char *pat, char *rpl);
-
-
-#endif /*REGEX_H*/
-
-/* End. */
-
diff --git a/psys/include/p2c/rnd.h b/psys/include/p2c/rnd.h
deleted file mode 100644
index 507c8a375532f85b6bf7b1106c255532e3b1d9fa..0000000000000000000000000000000000000000
--- a/psys/include/p2c/rnd.h
+++ /dev/null
@@ -1,12 +0,0 @@
-#ifndef RND_H
-#define RND_H
-
-#include <p2c/p2c.h>
-
-/**
- * Use the c library random methods
- */
-extern void P_random() DEPRECATED;
-extern long P_rand() DEPRECATED;
-
-#endif /* RND_H */
diff --git a/psys/include/p2c/strings.h b/psys/include/p2c/strings.h
deleted file mode 100644
index 165dd74609b696359c4a44cc49e9e1d6482f20e0..0000000000000000000000000000000000000000
--- a/psys/include/p2c/strings.h
+++ /dev/null
@@ -1,56 +0,0 @@
-#ifndef P2C_STRING_H
-#define P2C_STRING_H
-
-#include <p2c/p2c.h>
-
-/**
- * Append the second string to the first.
- *
- * DEPRECATED : use strcat instead
- */
-extern void strsafeappend(char *s, char *s2) DEPRECATED;
-
-//extern void strappendc(char *s, int ch);
-extern char *strupper (char *result, char *s);
-extern char *strlower (char *result, char *s);
-extern char *strpart (char *result, char *s, long fist, long last);
-extern char *strlast (char *result, char *s, size_t num);
-extern char *strreverse (char *result, char*);
-//extern char *strljust (char *result, char *s, long wid);
-//extern char *strrjust (char *result, char *s, long wid);
-extern char *strcjust (char *result, char *s, size_t wid);
-extern int strbegins (char *s1, char *s2);
-extern int strends (char *s1, char *s2);
-extern int strcibegins (char *s1, char *s2);
-extern int strciends (char *s1, char *s2);
-extern int strsubcmp (size_t n, char *s1, size_t i1, char *s2, size_t i2);
-extern int strcisubcmp (size_t n, char *s1, size_t i1, char *s2, size_t i2);
-extern void strsubst (char *repl, char *s, size_t index, size_t size);
-extern char *strint (char *result, long i);
-extern char *strint2 (char *result, long i, long w);
-//extern char *strreal (char *result, double r);
-extern char *strchar (char *result, int ch);
-//extern long strreadint (char *s);
-//extern double strreadreal (char *s);
-extern size_t strposb (char *s1, char *s2, ptrdiff_t i);
-extern size_t strposc (char *s1, char ch, ptrdiff_t i);
-extern size_t strposcset (char *s1, char *s2, size_t i);
-extern size_t strposbcset (char *s1, char *s2, size_t i);
-extern size_t strcipos2 (char *s1, char *s2, size_t i);
-extern size_t strciposb (char *s1, char *s2, size_t i);
-//extern int strcontains (char *s1, char *s2);
-extern int strsubset (char *s1, char *s2);
-extern int strcommon (char *s1, char *s2);
-extern size_t strlenv (char *s);
-extern char *strhex (char * Result, long i, long w);
-extern char *strbinary (char *Result, long i, size_t w);
-extern char *strdate (char *Result, char *opts);
-extern void strword (char *s, char *s2);
-extern void strword2 (char *s, char *s2);
-extern void strcomment (char *s, char* bracket);
-extern void strcompress (char *s, char *chars, int all);
-extern void strdispose (char **sp);
-extern void strchange (char** sp, char *);
-extern char *strcpy_overlap(char *dst, char *src) DEPRECATED;
-
-#endif
diff --git a/psys/include/p2c/strlist.h b/psys/include/p2c/strlist.h
deleted file mode 100644
index 91cf9c6b574e83cafa9cc8075bfa19992cb0a7b6..0000000000000000000000000000000000000000
--- a/psys/include/p2c/strlist.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef STRLIST_H
-#define STRLIST_H
-
-typedef struct strlist_t
-{
-	struct strlist_t *next;
-	void *value;    /* user-defined */
-	char kind;      /* user-defined */
-	size_t len;     /* for internal use */
-	char *s;
-} strlist_t;
-
-
-extern void strlist_init (strlist_t **base);
-extern strlist_t *strlist_find (strlist_t *base, char *s);
-extern strlist_t *strlist_cifind (strlist_t *base, char *s);
-extern void strlist_change (strlist_t **base, strlist_t **ptr, char *s);
-extern void strlist_remove (strlist_t **base, char *s);
-extern void strlist_delete (strlist_t **base, strlist_t **ptr);
-extern void strlist_dispose (strlist_t **ptr);
-extern void strlist_empty (strlist_t **base);
-extern void strlist_copy (strlist_t **dest, strlist_t *src);
-extern strlist_t *strlist_add (strlist_t **base, char *s);
-extern strlist_t *strlist_append (strlist_t **base, char *s);
-extern strlist_t *strlist_insert (strlist_t **base, char *s);
-
-extern void strlist_dump (FILE *f, strlist_t *base);
-
-
-#endif
-
diff --git a/psys/include/p2c/sysdevs.h b/psys/include/p2c/sysdevs.h
deleted file mode 100644
index dacf57a356dd44a6688227d970a9e7aaacbd8b73..0000000000000000000000000000000000000000
--- a/psys/include/p2c/sysdevs.h
+++ /dev/null
@@ -1,26 +0,0 @@
-#ifndef SYSDEVS_H
-#define SYSDEVS_H
-
-#include <p2c/sysglobals.h>
-
-#ifdef SYSDEVS_G
-# define vextern
-#else
-# define vextern extern
-#endif
-
-
-/** CLOCK ************************************************/
-extern long sysclock ();
-
-extern void sysdate (daterec *thedate);
-extern void systime (timerec *thetime);
-extern void setsysdate (daterec thedate);
-extern void setsystime (timerec thetime);
-
-#undef vextern
-
-#endif /*SYSDEVS_H*/
-
-/* End. */
-
diff --git a/psys/src/COPYING b/psys/src/COPYING
deleted file mode 100644
index 9a170375811150e8f01ab7b88513aeeee5e527d1..0000000000000000000000000000000000000000
--- a/psys/src/COPYING
+++ /dev/null
@@ -1,249 +0,0 @@
-
-		    GNU GENERAL PUBLIC LICENSE
-		     Version 1, February 1989
-
- Copyright (C) 1989 Free Software Foundation, Inc.
-                    675 Mass Ave, Cambridge, MA 02139, USA
- Everyone is permitted to copy and distribute verbatim copies
- of this license document, but changing it is not allowed.
-
-			    Preamble
-
-  The license agreements of most software companies try to keep users
-at the mercy of those companies.  By contrast, our General Public
-License is intended to guarantee your freedom to share and change free
-software--to make sure the software is free for all its users.  The
-General Public License applies to the Free Software Foundation's
-software and to any other program whose authors commit to using it.
-You can use it for your programs, too.
-
-  When we speak of free software, we are referring to freedom, not
-price.  Specifically, the General Public License is designed to make
-sure that you have the freedom to give away or sell copies of free
-software, that you receive source code or can get it if you want it,
-that you can change the software or use pieces of it in new free
-programs; and that you know you can do these things.
-
-  To protect your rights, we need to make restrictions that forbid
-anyone to deny you these rights or to ask you to surrender the rights.
-These restrictions translate to certain responsibilities for you if you
-distribute copies of the software, or if you modify it.
-
-  For example, if you distribute copies of a such a program, whether
-gratis or for a fee, you must give the recipients all the rights that
-you have.  You must make sure that they, too, receive or can get the
-source code.  And you must tell them their rights.
-
-  We protect your rights with two steps: (1) copyright the software, and
-(2) offer you this license which gives you legal permission to copy,
-distribute and/or modify the software.
-
-  Also, for each author's protection and ours, we want to make certain
-that everyone understands that there is no warranty for this free
-software.  If the software is modified by someone else and passed on, we
-want its recipients to know that what they have is not the original, so
-that any problems introduced by others will not reflect on the original
-authors' reputations.
-
-  The precise terms and conditions for copying, distribution and
-modification follow.
-
-		    GNU GENERAL PUBLIC LICENSE
-   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
-  0. This License Agreement applies to any program or other work which
-contains a notice placed by the copyright holder saying it may be
-distributed under the terms of this General Public License.  The
-"Program", below, refers to any such program or work, and a "work based
-on the Program" means either the Program or any work containing the
-Program or a portion of it, either verbatim or with modifications.  Each
-licensee is addressed as "you".
-
-  1. You may copy and distribute verbatim copies of the Program's source
-code as you receive it, in any medium, provided that you conspicuously and
-appropriately publish on each copy an appropriate copyright notice and
-disclaimer of warranty; keep intact all the notices that refer to this
-General Public License and to the absence of any warranty; and give any
-other recipients of the Program a copy of this General Public License
-along with the Program.  You may charge a fee for the physical act of
-transferring a copy.
-
-  2. You may modify your copy or copies of the Program or any portion of
-it, and copy and distribute such modifications under the terms of Paragraph
-1 above, provided that you also do the following:
-
-    a) cause the modified files to carry prominent notices stating that
-    you changed the files and the date of any change; and
-
-    b) cause the whole of any work that you distribute or publish, that
-    in whole or in part contains the Program or any part thereof, either
-    with or without modifications, to be licensed at no charge to all
-    third parties under the terms of this General Public License (except
-    that you may choose to grant warranty protection to some or all
-    third parties, at your option).
-
-    c) If the modified program normally reads commands interactively when
-    run, you must cause it, when started running for such interactive use
-    in the simplest and most usual way, to print or display an
-    announcement including an appropriate copyright notice and a notice
-    that there is no warranty (or else, saying that you provide a
-    warranty) and that users may redistribute the program under these
-    conditions, and telling the user how to view a copy of this General
-    Public License.
-
-    d) You may charge a fee for the physical act of transferring a
-    copy, and you may at your option offer warranty protection in
-    exchange for a fee.
-
-Mere aggregation of another independent work with the Program (or its
-derivative) on a volume of a storage or distribution medium does not bring
-the other work under the scope of these terms.
-
-  3. You may copy and distribute the Program (or a portion or derivative of
-it, under Paragraph 2) in object code or executable form under the terms of
-Paragraphs 1 and 2 above provided that you also do one of the following:
-
-    a) accompany it with the complete corresponding machine-readable
-    source code, which must be distributed under the terms of
-    Paragraphs 1 and 2 above; or,
-
-    b) accompany it with a written offer, valid for at least three
-    years, to give any third party free (except for a nominal charge
-    for the cost of distribution) a complete machine-readable copy of the
-    corresponding source code, to be distributed under the terms of
-    Paragraphs 1 and 2 above; or,
-
-    c) accompany it with the information you received as to where the
-    corresponding source code may be obtained.  (This alternative is
-    allowed only for noncommercial distribution and only if you
-    received the program in object code or executable form alone.)
-
-Source code for a work means the preferred form of the work for making
-modifications to it.  For an executable file, complete source code means
-all the source code for all modules it contains; but, as a special
-exception, it need not include source code for modules which are standard
-libraries that accompany the operating system on which the executable
-file runs, or for standard header files or definitions files that
-accompany that operating system.
-
-  4. You may not copy, modify, sublicense, distribute or transfer the
-Program except as expressly provided under this General Public License.
-Any attempt otherwise to copy, modify, sublicense, distribute or transfer
-the Program is void, and will automatically terminate your rights to use
-the Program under this License.  However, parties who have received
-copies, or rights to use copies, from you under this General Public
-License will not have their licenses terminated so long as such parties
-remain in full compliance.
-
-  5. By copying, distributing or modifying the Program (or any work based
-on the Program) you indicate your acceptance of this license to do so,
-and all its terms and conditions.
-
-  6. Each time you redistribute the Program (or any work based on the
-Program), the recipient automatically receives a license from the original
-licensor to copy, distribute or modify the Program subject to these
-terms and conditions.  You may not impose any further restrictions on the
-recipients' exercise of the rights granted herein.
-
-  7. The Free Software Foundation may publish revised and/or new versions
-of the General Public License from time to time.  Such new versions will
-be similar in spirit to the present version, but may differ in detail to
-address new problems or concerns.
-
-Each version is given a distinguishing version number.  If the Program
-specifies a version number of the license which applies to it and "any
-later version", you have the option of following the terms and conditions
-either of that version or of any later version published by the Free
-Software Foundation.  If the Program does not specify a version number of
-the license, you may choose any version ever published by the Free Software
-Foundation.
-
-  8. If you wish to incorporate parts of the Program into other free
-programs whose distribution conditions are different, write to the author
-to ask for permission.  For software which is copyrighted by the Free
-Software Foundation, write to the Free Software Foundation; we sometimes
-make exceptions for this.  Our decision will be guided by the two goals
-of preserving the free status of all derivatives of our free software and
-of promoting the sharing and reuse of software generally.
-
-			    NO WARRANTY
-
-  9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
-FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
-OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
-PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
-OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
-TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
-PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
-REPAIR OR CORRECTION.
-
-  10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
-WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
-REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
-INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
-OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
-TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
-YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
-PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
-POSSIBILITY OF SUCH DAMAGES.
-
-		     END OF TERMS AND CONDITIONS
-
-	Appendix: How to Apply These Terms to Your New Programs
-
-  If you develop a new program, and you want it to be of the greatest
-possible use to humanity, the best way to achieve this is to make it
-free software which everyone can redistribute and change under these
-terms.
-
-  To do so, attach the following notices to the program.  It is safest to
-attach them to the start of each source file to most effectively convey
-the exclusion of warranty; and each file should have at least the
-"copyright" line and a pointer to where the full notice is found.
-
-    <one line to give the program's name and a brief idea of what it does.>
-    Copyright (C) 19yy  <name of author>
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 1, or (at your option)
-    any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
-Also add information on how to contact you by electronic and paper mail.
-
-If the program is interactive, make it output a short notice like this
-when it starts in an interactive mode:
-
-    Gnomovision version 69, Copyright (C) 19xx name of author
-    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
-    This is free software, and you are welcome to redistribute it
-    under certain conditions; type `show c' for details.
-
-The hypothetical commands `show w' and `show c' should show the
-appropriate parts of the General Public License.  Of course, the
-commands you use may be called something other than `show w' and `show
-c'; they could even be mouse-clicks or menu items--whatever suits your
-program.
-
-You should also get your employer (if you work as a programmer) or your
-school, if any, to sign a "copyright disclaimer" for the program, if
-necessary.  Here a sample; alter the names:
-
-  Yoyodyne, Inc., hereby disclaims all copyright interest in the
-  program `Gnomovision' (a program to direct compilers to make passes
-  at assemblers) written by James Hacker.
-
-  <signature of Ty Coon>, 1 April 1989
-  Ty Coon, President of Vice
-
-That's all there is to it!
diff --git a/psys/src/Makefile b/psys/src/Makefile
deleted file mode 100644
index 870a91c82994391699553c973153c381edba4158..0000000000000000000000000000000000000000
--- a/psys/src/Makefile
+++ /dev/null
@@ -1,268 +0,0 @@
-# "PSYS", p-system emulation libraries for the Caltech tools,
-#
-#   Copyright (C) 1983, 1990, 1993 California Institute of Technology.
-#   Authors: Dave Gillespie, Rick Koshi, Glenn Gribble, Adam Greenblatt
-#   Maintainers: John Lazzaro and Dave Gillespie
-#   Maintainers's address: lazzaro@cs.berkeley.edu;
-#                          EECS/571 Evans Hall/UCB/Berkeley CA 94720
-#                          daveg@synaptics.com;
-#                          Send questions, bug fixes, to these addresses.
-#
-#
-#This program is free software; you can redistribute it and/or modify
-#it under the terms of the GNU General Public License as published by
-#the Free Software Foundation (Version 1, 1989).
-#
-#This program is distributed in the hope that it will be useful,
-#but WITHOUT ANY WARRANTY; without even the implied warranty of
-#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#GNU General Public License for more details.
-#
-#You should have received a copy of the GNU General Public License
-#along with this program; see the file COPYING.  If not, write to
-#the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
-# Makefile for Chipmunk CAD Pascal emulation libraries.  Version 1.61
-
-
-## comment blocks in this Makefile point to possible changes that need
-## to be made for different systems. Its a good idea to look over each
-## block and make necessary changes before doing a "make install"
-
-LIBDIR = ../../lib
-BINDIR = ../../bin
-
-
-LIB = ../libp2c.a
-
-LOCINC = ../include
-
-##
-## If X isn't in the include path, change XINCLUDEDIR:
-##
-## For modern Linux distributions, try:
-##
-## XINCLUDEDIR = /usr/include/X11
-##
-## or maybe
-##
-## XINCLUDEDIR = /usr/X11/include
-##
-## For OS X, this usually works:
-##
-## XINCLUDEDIR = /usr/X11R6/include
-##
-## For most versions of UNIX, one of the above directories
-## will be the correct one to use on the line below:
-
-XINCLUDEDIR = .
-
-
-##
-## (0) 64-bit Linux issues
-## -----------------------
-##
-## The Chipmunk tools must be built as 32-bit applications.
-## Under 64-bit Linux systems, it may be necessary to install
-## special packages to build 32-bit applications. A common
-## symptom of this problem will be the error message:
-##
-## cannot find /usr/include/gnu/stubs-32.h
-##
-## This can be fixed by installing glibc-devel.i686.
-##
-
-
-##
-##  (1) Choosing your compiler
-##  ---------------------------
-##
-##
-## For most Unix architectures, a stable gcc 2.X will work well.
-##
-## For IBM RS/6000, xlc is recommended.
-##
-## Note than for HP series 700/800, the default cc won't work; the
-## extra-cost ANSI cc is needed. Gcc works well on HP series 700/800.
-##
-## For AmigaOS, ADE (Amiga Development Enviroment) with gcc is recommended.
-##
-
-CHIPMUNKCC = gcc -O3
-
-OBJS = sysdevs.o \
-       misc.o \
-       newci.o \
-       filepack.o \
-       iodecl.o \
-       mylib.o \
-       newkbd.o \
-       strings.o \
-       strlist.o \
-       newasmlib.o \
-       newcrt.o \
-       rnd.o \
-       regex.o \
-       p2clib.o \
-
-LIBSTUFF = texstuff.ps untilstuff.ps plot.font
-
-
-CC = $(CHIPMUNKCC)
-
-
-##
-## (2) The "cd" problem
-## ---------------------
-##
-## If you have aliased "cd" to some other command in your .cshrc,
-## change the following definition to:
-##
-## CD = chdir
-##
-## or specify the complete command path.
-
-CD = cd
-
-##
-## (3) Choosing default fonts
-## --------------------------
-##
-## By default, Chipmunk expects the Xserver to have
-## the 6x10 and 8x13 fonts available. This default
-## may be overriden via .Xresources. To change the
-## the default fonts, define FONTS as with the syntax:
-##
-## FONTS = -DNEWCRT_FONT=\"8x13\" -DMYLIB_FONT=\"6x10\"
-##
-## and change the double-quoted fonts to reflect the
-## fonts available for your system. For example, try:
-##
-## FONTS = -DNEWCRT_FONT=\"7x13\" -DMYLIB_FONT=\"6x12\"
-##
-
-FONTS =
-
-##
-## (4) Adding appropriate flags
-## -----------------------------
-##
-## Add these flags to the CHIPMUNKFLAGS below:
-##
-## Linux/86                     -m32
-## Apple OS X                   -m32
-## FreeBSD                      -m32
-
-CHIPMUNKFLAGS = $(ARCH_OPT)
-
-OPTIONS = -Wall -Wextra
-
-CFLAGS = $(CHIPMUNKFLAGS) $(OPTIONS) $(FONTS) -I$(LOCINC) -I$(XINCLUDEDIR) -DCHIPLIB="\"`$(CD) $(LIBDIR); pwd`\""
-
-P2CFLAGS =
-
-
-##
-## (5) Ranlib problems
-## -------------------
-##
-## For Apple Macintosh OS X, add the -c flag to CHIPMUNKRANFLAGS below.
-##
-
-CHIPMUNKRANFLAGS =
-
-## for systems without ranlib, you may wish to delete the lines:
-##
-## -ranlib -t $(LIB)
-## -ranlib libp2c.a
-##
-## below; however the "-" allows this to be non-fatal and thus not essential
-## to delete
-
-
-all: setup libp2c.a
-
-setup:
-	-if [ ! -d $(LIBDIR) ] ; then mkdir $(LIBDIR) ; fi
-
-install: setup all
-	cp libp2c.a $(LIB)
-	-ranlib $(CHIPMUNKRANFLAGS) -t $(LIB)
-	cp $(LIBSTUFF) $(LIBDIR)
-	-if [ ! -d $(BINDIR) ] ; then mkdir $(BINDIR) ; fi
-
-libp2c.a: $(OBJS)
-	-rm -f libp2c.a
-	ar r libp2c.a $(OBJS)
-	-ranlib $(CHIPMUNKRANFLAGS) libp2c.a
-
-p2clib.o: p2clib.c
-	$(CC) -c $(CFLAGS) $(P2CFLAGS) p2clib.c
-
-clean:
-	-rm -f *.o libp2c.a ../libp2c.a
-
-## The following part of the Makefile is for making a tar file of the
-## original parts of the psys distribution. Most users have no need for it.
-
-VERSION = 1.61
-
-create: dist createit
-
-createit:
-	tar cvf psys.tar psys
-	rm -f psys.tar.gz
-	gzip psys.tar
-
-dist: pdistrib psysinc psyssrc
-
-pdistrib:
-	rm -rf psys
-	mkdir psys
-	mkdir psys/include
-	mkdir psys/include/p2c
-	mkdir psys/src
-
-psysinc:
-	cp ../include/p2c/p2c.h psys/include/p2c
-	cp ../include/p2c/sysglobals.h psys/include/p2c
-	cp ../include/p2c/sysdevs.h psys/include/p2c
-	cp ../include/p2c/misc.h psys/include/p2c
-	cp ../include/p2c/newci.h psys/include/p2c
-	cp ../include/p2c/filepack.h psys/include/p2c
-	cp ../include/p2c/citinfomod.h psys/include/p2c
-	cp ../include/p2c/newkbd.h psys/include/p2c
-	cp ../include/p2c/newasm.h psys/include/p2c
-	cp ../include/p2c/newcrt.h psys/include/p2c
-	cp ../include/p2c/regex.h psys/include/p2c
-	cp ../include/p2c/plot.h psys/include/p2c
-	cp ../include/p2c/plot_routines.h psys/include/p2c
-	cp ../include/p2c/rnd.h psys/include/p2c
-	cp ../include/p2c/iodecl.h psys/include/p2c
-	cp ../include/p2c/mylib.h psys/include/p2c
-	cp ../include/p2c/strings.h psys/include/p2c
-
-psyssrc:
-	cp asm.c psys/src
-	cp filepack.c psys/src
-	cp iodecl.c psys/src
-	cp mamplot.c psys/src
-	cp misc.c psys/src
-	cp mylib.c psys/src
-	cp newasmlib.c psys/src
-	cp newci.c psys/src
-	cp newcrt.c psys/src
-	cp newkbd.c psys/src
-	cp p2clib.c psys/src
-	cp plot.c psys/src
-	cp plot.font psys/src
-	cp regex.c psys/src
-	cp rnd.c psys/src
-	cp sysdevs.c psys/src
-	cp texstuff.ps psys/src
-	cp untilstuff.ps psys/src
-	cp README psys/src/README
-	sed -e "s;1.61;$(VERSION);" Makefile >psys/src/Makefile
-	sed -e "s;1.61;$(VERSION);" Makefile.os2 >psys/src/Makefile.os2
-	cp COPYING psys/src/COPYING
-
diff --git a/psys/src/README b/psys/src/README
deleted file mode 100644
index 4f2a0f6bc8374ff1a7963bf29a11f6ad8b7ce174..0000000000000000000000000000000000000000
--- a/psys/src/README
+++ /dev/null
@@ -1,338 +0,0 @@
-
-This is psys, a library that most of the Chipmunk tools use for low-level
-operations. If you have a web browser, the best way to learn about what
-Psys is and how to install it is to pick up the latest version of the 
-webdoc Web pages (webdocX.XX.tar.gz, where X.XX is a version number) from
-the same place you picked up this file. Once you have this Web tree
-untarred, point your Web browser (examples of Web browsers include
-Mosaic, Lynx, Netscape, and tkWWW) to webdoc/index.html for the home
-page of the Chipmunk tools, and to webdoc/compile/compile.html for
-compilation instructions.
-
-The rest of this file is written assuming that you don't have access
-to a Web browser -- all text is copied from webdoc pages
-verbatim. I'll do my best to keep this file up to date, but the Web
-tree is now the primary documentation for all aspects of the Chipmunk
-system.
-
----------
-
-This is psys, the p-system emulation libraries for the caltech tools.
-Psys was written by Dave Gillespie, Rick Koshi, Glenn Gribble,
-Adam Greenblatt, and Maryann Maher and is maintained under Unix by Dave
-Gillespie and John Lazzaro.  Psys is distributed under the GNU General
-Public License; see file COPYING in this directory for more
-information.
-
-Psys's purpose in life is to support the graphical tools in the
-Caltech CAD distribution: analog, wol, view, and until. These libraries
-must be installed before attempting to install these tools.
-
-Platforms and Requirements 
-
-The Chipmunk tools require an ANSI c compiler (typically GCC) and X11
-(R4, R5, or R6).  Monochrome, 8-bit, 16-bit, and 24-bit per pixel
-color displays are supported; however, 16-bit and 24-bit color modes
-have only been tested on PC platforms (X11 under Linux and OS/2). An
-HTML browser (like Mosaic or Lynx or Netscape) is also necessary to
-access the Chipmunk documentation.
-
-These are the currently supported platforms, with details of
-platform-specific requirements: 
-
-   AmigaOS. Requires ADE X or AmiWin X11. 
-   Apple Macintosh, OS/X, AU/X, and MachTen
-   DEC MIPS-based DECstations 
-   DEC Linux/Alpha. OSF/1(Digital Unix) not tested, but may also work. 
-   HP Series 300/400, HPUX. 
-   HP Series 700, HPUX. The HP-supplied cc, with extra-cost
-   ANSI option, will also compile Chipmunk. 
-   IBM PC and Compatibles, FreeBSD. 
-   IBM PC and Compatibles, Linux/x86. 
-   IBM RS/6000. The IBM xlc compiler is known to compile
-   Chipmunk; gcc has not been tested. 
-   SGI, Irix 5.2/5.3, cc or gcc. 
-   Sun SPARC, Solaris 1.X (SunOS 4.X). 
-   Sun SPARC, Solaris 2.X (SunOS 5.X). 
-   IBM PC and Compatibles, OS/2. 
-
-     OS/2 Requirements 
-
-     Only the Log system (diglog, analog and loged) is ported. Here are the
-     requirements for Log:
-
-     WARP Connect.
- 
-     The PMX server (The X Window System for OS/2) About $140 US, availible
-     from Indelible Blue, 800-776-8284. 
-
-     The icc compiler, and nmake. Not known if gcc will work also, please
-     let me know if you try gcc. 
-
-
-Binary distributions have been built by third-parties for the
-following architectures. Contact the authors for additional
-information.
-
-IBM PC-Compatibles, MS-DOS. Luigi Rizzo's group at the Universita' di
-Pisa, Italy, has been working on an MS-DOS port of analog. Compiled
-with djgpp, uses xlibemu and fvwm to provide an interface similar to a
-virtual window manager under X with Motif-like widgets. See his home
-page for current status; there may be an early-alpha version of a
-binary available for evaluation (see "Materiale didattico" section).
-(http://www.iet.unipi.it/~luigi/) 
-
-Amiga. Marco Gigante (se62@galileo.iet.unipi.it) has created a binary
-distribution for the Amiga, which uses the ADE X or AmiWin X
-server. These binaries are available on the Aminet server
-(ftp://ftp.wustl.edu/pub/aminet/misc/sci/), for several hardware
-configurations. Binary filesets ChipMunk*.lha, log*.lha, view*.lha,
-until*.lha, wol*.lha, contain the distributions for Chipmunk, Log,
-View, Until, and Wol respectively.
-
-If your configuration is different than the ones described above, only
-take the package if you feel confident in your C/Unix abilities to do
-the porting required. If you do successfully port to a new
-architecture or OS, send us the changes required, and we will
-incorporate your port in the next release of the chipmunk tools.
-
-Absent from this list are the following popular platforms. 
-
-IBM PC-Compatibles, Windows NT No ports are in progress, to my knowledge. 
-
-IBM PC-Compatibles, NextStep. No ports are in progress, to my knowledge. 
-
-Apple Macintosh, MacOS. No ports are in progress, to my knowledge. However,
-MachTen does run as a process on top of MacOS. 
-
-
-
-			INSTALLING PSYS
-			---------- ----
-
-Chipmunk System Setup 
-----------------------
-
-The first part of setting up a Chipmunk system is to choose a place in
-your directory tree for the tools. Chipmunk can be installed in a user
-directory; you do not need to install it in a public place like 
-/usr/local/. Once you've decided on a place, create a directory
-called chipmunk. Now move all the Chipmunk tar files to the 
-chipmunk directory, and uncompress them using gzip if necessary.
-
-Next, un-tar the files using the tar command, with the options
-appropriate for your system. For most Unix systems, the command 
-
-tar -xf file.tar 
-
-untars the file file.tar. Once this is complete, a directory listing
-of chipmunk should include the following directories 
-
-webdoc/ psys/ 
-
-as well as some of the following directories, depending on which
-applications you pickup up. 
-
-log/ mosis/ netcmp/ until/ util/ view/ wol/
-wolcomp/ 
-
-Compiling Psys 
-
-This document assumes you are compiling the Psys libraries for one of
-the currently supported machines, and that you have the required
-support software detailed in this document. This document also
-assumes that you have uncompressed and untarred the Psys file, and
-installed it in the chipmunk directory. 
-
-
-Begin by descending to the psys/src directory. At this point OS/2
-users only should execute the following command. 
-      ----
-
-cp Makefile.os2 Makefile 
-
-All users should now edit the Makefile, and make any necessary
-changes. Comments in the Makefile will guide you through these
-changes; the changes are labeled with the markers (1), (2), (3), etc. Once
-these changes are made, execute the command 
-
-make install 
-
-If things are working correctly, a long series of compilations, linkings,
-and file movements should occur without error. When these operations
-complete, Psys is successfully installed. 
-
-Problems and Solutions 
------------------------
-
-It is quite possible that compilation did not proceed smoothly. Here are
-some problems that could have happened, along with suggestions. 
-
-ANSI header problems 
-
-   Sometimes, not all the /usr/include/*.h files are ANSI
-   standard, especially in older machines. Symptoms of this
-   problem include mention of the stdlib.h and stddef.h
-   header files in the compilation error message, and mention of
-   the _SIZE_T and _PTRDIFF_T defines in the compilation
-   error message. There are several possible solutions to this problem,
-   depending on your machine configuration; they are listed in order of
-   probability of working: 
-
-    1. Make a file stdlib.h in the directory psys/include,
-    that contains one line: the string #include
-    <sys/types.h>. This file may help for the compilation of
-    some files but break the compilation of other files; if so, delete
-    and re-make the file as needed. 
-    2. Undo the change described in 1. above, and add -D_SIZE_T
-     -D_PTRDIFF_T to the CFLAGS definition in the Makefile. 
-    3. Undo the change described in 2. above, and add the empty files 
-    stddef.h and stdlib.h in the directory 
-    psys/include. These files may help for the compilation of
-    some files but break the compilation of other files; if so, delete
-    and re-make the files as needed. 
-
-Ranlib problems 
-   On some systems, it may be necessary to run ranlib on the
-   file libp2c.a for linking to be successfull. 
-
-Font problems 
-   The Chipmunk system expects the X fonts 8x13and 6x10 to
-   be available. Some minimal systems don't have these. If you
-   don't have them, search for the string DefaultFont in 
-   psys/src/newcrt.c and psys/src/mylib.c, and
-   change the definitions to be similarly-sized fonts that are in
-   your system. 
-
-Gcc installation problems 
-   Sometimes Gcc is installed incorrectly in a system, and the
-   Chipmunk tools are the first program that reveal the incorrect
-   installation. Examples problems include Gcc using the cc
-   preprocessor instead of its own preprocessor, and Gcc is
-   looking in the wrong place for include files. When compiling
-   the Chipmunk tools, a symptom of these problems often
-   involves problems with accessing the system include file 
-   varargs.h. 
-
-Putc definition problems (Linux users only) 
-   The putc definition in newcrt.c is set up for the current
-   Slackware distribution of Linux. If newcrt.c does not
-   compile for you under Linux, search in newcrt.c for the
-   word dreaded for more information. 
-
-Email support for Chipmunk Users 
---------------------------------
-
-If you are having trouble creating a working version of the Chipmunk
-tools, please let me know, and I'll try to offer help. 
-
-Send email to lazzaro@cs.berkeley.edu and include the
-following information.
-
-   Complete machine configuration, including machine type, OS
-   revision, compilers, and X servers. 
-
-   A listing of the output from the failed compilation process, or
-   any messages printed by a Chipmunk program or the OS or X
-   when an error occurs. 
-
-   Details of any changes you have made to the distribution before
-   this compilation. 
-
-   The effects of following any advice given in the compilation
-   instructions. 
-
-Chipmunk and X 
----------------
-
-Chipmunk and X: Color Depth 
-
-Chipmunk tools currently support monochrome, 8-bit, 16-bit, and 24-bit
-displays. The 16-bit and 24-bit display modes are only known to work
-on the PC architecture (X11 under Linux and OS/2); see this document
-for more details on the current status of color support.
-
-By default, the Chipmunk tools select a color mode using these rules:
-
-If Pseudo-Color mode is supported with a depth of at least 8
-bits, the tool uses 8-bit mode.
-
-If Pseudo-Color mode is not supported but TrueColor mode is supported,
-the tool uses 24-bit depth if available, or 16-bit depth if 24-bit
-depth is not available.
-
-If all else fails, monochrome mode is selected. 
-
-The user can force the color mode of a Chipmunk tool by setting the
-environment variable LOG_COLOR to be the string bw or 8bit or 16bit or
-24bit.
-
-Chipmunk and X: Window Placement 
-
-Manually placing and sizing the mylib and newcrt windows can
-quickly become tedious. The Chipmunk tools can automatically size
-and place these windows. To enable this feature, you'll need to add
-information to an X initialization file in your home directory,
-typically named .Xresources. Three resources are implemented
-for the Chipmunk tools: 
-
-mylib.geometry: =AxB+C+D 
-   You can use this resource to set the size of the mylib window
-   to have an X dimension of A pixels, and a Y dimension of B
-   pixels, and have it automatically placed at the position indicated
-   by C (x placement) and D (y placement). 
-newcrt.geometry: +C+D 
-   The size of the newcrt window is fixed for all Chipmunk
-   tools. This resource automatically places the newcrt window
-   at a position indicated by C (x placement) and D (y placement). 
-mylib.color black_and_white 
-   This X resource forces Chipmunk tools to generate
-   monochrome displays, even if the machine has a color monitor. 
-
-You will need to exit and restart your X server after changing you 
-.Xresources file to activate the new behavior.
-
-
-Examples 
-
-My .Xresources for my color Sun IPC machine is as follows: 
-
-mylib.geometry: =1150x550+0+0
-
-newcrt.geometry: +510+586
-
-My .Xresources for my HP 712/80 machine, which has a higher-resolution
-monitor, is
-
-mylib.geometry: =1278x682+0+0
-
-newcrt.geometry: +638+710
-
-These features were added to the Chipmunk tools by Jim Clark at
-Harvard University, Tor Sverre Lande at IFI, and Michael Godfrey at
-Stanford University.
-
-	                    Closing Remarks
-	                  ------------------
-
-This is a preliminary release of the P-system libraries.  Some have
-been translated from a different language and operating system; others
-are hand-written emulations.  A few bugs and weaknesses arising from
-the translation process still remain.  Correspondence on the P-system
-emulation library should be sent to daveg@synaptics.com and
-lazzaro@cs.berkeley.edu.
-
-						-- Dave Gillespie, San Jose
-						-- John Lazzaro, Berkeley
-						
-
-
-
-
-
-
-
-
-
-
-
diff --git a/psys/src/iodecl.c b/psys/src/iodecl.c
deleted file mode 100644
index d59ffed48c0b83b30ebeebbaea7f0b5ada669437..0000000000000000000000000000000000000000
--- a/psys/src/iodecl.c
+++ /dev/null
@@ -1,5 +0,0 @@
-#define IODECLARATIONS_G
-
-#include <stdio.h>
-#include <p2c/p2c.h>
-#include <p2c/iodecl.h>
diff --git a/psys/src/rnd.c b/psys/src/rnd.c
deleted file mode 100644
index 95857307034e1c44330ee0044a544fadbec5181c..0000000000000000000000000000000000000000
--- a/psys/src/rnd.c
+++ /dev/null
@@ -1,25 +0,0 @@
-#include <stdlib.h>
-#include <p2c/rnd.h>
-
-
-void P_random(long *seed)
-{
-  
-  srand48(*seed);
-  *seed = lrand48();
-}
-
-
-long P_rand(long *seed, long limit)
-{
-
-  srand48(*seed);
-  *seed = lrand48();
-  if (limit != 0)
-    return(abs(*seed % limit)); /* I know, I know.  This skews probabilities */
-			        /* slightly toward low numbers unless limit  */
-			        /* is a divisor of 2^32.  Tough.             */
-  else
-    return(0);
-}  
-  
diff --git a/log/src/ana/capfloat.c b/src/ana/capfloat.c
similarity index 99%
rename from log/src/ana/capfloat.c
rename to src/ana/capfloat.c
index 66586f2585535ee769c799b58b6f5cdbe79d6dfd..464c61a9a16a32c10205317e01be1e52aa58dece 100644
--- a/log/src/ana/capfloat.c
+++ b/src/ana/capfloat.c
@@ -23,7 +23,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 /* Output from p2c, the Pascal-to-C translator */
 /* From input file "gates.text" */
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/capfloat.h"
 #include "node.h"
 
diff --git a/log/src/ana/devtechn.c b/src/ana/devtechn.c
similarity index 99%
rename from log/src/ana/devtechn.c
rename to src/ana/devtechn.c
index 94d27b4cd1c1908a4f2b04839a4f08f7ade0d0a7..2f9ea764f354e34221abed1005a625b00d89f793 100644
--- a/log/src/ana/devtechn.c
+++ b/src/ana/devtechn.c
@@ -25,7 +25,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/devtechn.h"
 
 #define N_process      1
diff --git a/log/src/ana/devtechp.c b/src/ana/devtechp.c
similarity index 99%
rename from log/src/ana/devtechp.c
rename to src/ana/devtechp.c
index 884a748714f4bfa9a66fb5ca1ec3adeb10094517..6244c2fe119e995bb91d08e2edd984055c2f9758 100644
--- a/log/src/ana/devtechp.c
+++ b/src/ana/devtechp.c
@@ -25,7 +25,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/devtechp.h"
 
 #define N_process      1
diff --git a/log/src/ana/diode1.c b/src/ana/diode1.c
similarity index 99%
rename from log/src/ana/diode1.c
rename to src/ana/diode1.c
index 1220680d833a7543652b94d1f2f184c710de8c05..9c3e1f7b00bb9d3348838a18b8d16e4744ede16f 100644
--- a/log/src/ana/diode1.c
+++ b/src/ana/diode1.c
@@ -23,7 +23,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 /* Output from p2c, the Pascal-to-C translator */
 /* From input file "scott.text" */
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/diode1.h"
 #include "node.h"
 
diff --git a/log/src/ana/ganglion.c b/src/ana/ganglion.c
similarity index 99%
rename from log/src/ana/ganglion.c
rename to src/ana/ganglion.c
index 04720aaa1dbe93c0a67eaf3fd2a0545a40e72195..755519a8d528307ce711a0f6a0aa5fdcd52f4e7b 100644
--- a/log/src/ana/ganglion.c
+++ b/src/ana/ganglion.c
@@ -27,7 +27,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 /*When its time to add subthreshold light, look at IDIFF for new update,
   write procedures*/
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/ganglion.h"
 #include "node.h"
 
diff --git a/log/src/ana/globals.c b/src/ana/globals.c
similarity index 99%
rename from log/src/ana/globals.c
rename to src/ana/globals.c
index a769f22d118152595f961936f4c80b2401fa57f8..497527b84b6aef720c2721cda3712c4facf0b43c 100644
--- a/log/src/ana/globals.c
+++ b/src/ana/globals.c
@@ -30,7 +30,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 
 
 #define GLOBALS_G
@@ -38,7 +38,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 #include "node.h"
 
 #ifndef NEWCRT_H
-#include <p2c/newcrt.h>
+#include <graphics/newcrt.h>
 #endif
 
 
diff --git a/log/src/ana/hres.c b/src/ana/hres.c
similarity index 99%
rename from log/src/ana/hres.c
rename to src/ana/hres.c
index 50478924a0aa5ae322c4146e7b3f59e92ebaad8e..c67fd97c1fc1611a4ae6c9adfc92f83d681c3374 100644
--- a/log/src/ana/hres.c
+++ b/src/ana/hres.c
@@ -27,7 +27,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 /*When its time to add subthreshold light, look at IDIFF for new update,
   write procedures*/
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/hres.h"
 #include "node.h"
 
diff --git a/log/src/ana/idiff.c b/src/ana/idiff.c
similarity index 99%
rename from log/src/ana/idiff.c
rename to src/ana/idiff.c
index 22ffe034e3b695bca84214e6eeca423e2a8cd173..7761a5a92071c019c9b77d21bf2293628b813125 100644
--- a/log/src/ana/idiff.c
+++ b/src/ana/idiff.c
@@ -25,7 +25,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "node.h"
 
 
diff --git a/log/src/ana/inter.c b/src/ana/inter.c
similarity index 99%
rename from log/src/ana/inter.c
rename to src/ana/inter.c
index b1b39e6d6c74ed41dc598e42ed22820629103aec..b8e5dbed8e329f9e24967d2120d36d958d70950d 100644
--- a/log/src/ana/inter.c
+++ b/src/ana/inter.c
@@ -26,7 +26,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 
 
 #define INTER_G
diff --git a/log/src/ana/iscope.c b/src/ana/iscope.c
similarity index 99%
rename from log/src/ana/iscope.c
rename to src/ana/iscope.c
index af92625ef2e71d4efcf4d2a0300c08d204b4082c..777cde4670e1102fe4d2819c383eb3dc2b9f840d 100644
--- a/log/src/ana/iscope.c
+++ b/src/ana/iscope.c
@@ -25,7 +25,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/iscope.h"
 #include "node.h"
 
diff --git a/log/src/ana/iswitch1.c b/src/ana/iswitch1.c
similarity index 99%
rename from log/src/ana/iswitch1.c
rename to src/ana/iswitch1.c
index 6a6377e01461c5b26dc0601b84ec86f793e55fe3..4425272c228f2d89d147004e6b6a727afc5224a7 100644
--- a/log/src/ana/iswitch1.c
+++ b/src/ana/iswitch1.c
@@ -25,7 +25,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/iswitch1.h"
 #include "node.h"
 
diff --git a/log/src/ana/iswitch2.c b/src/ana/iswitch2.c
similarity index 99%
rename from log/src/ana/iswitch2.c
rename to src/ana/iswitch2.c
index c5d52df24e391557cf4d0dc45535090797ac66d6..6fb4323c76db3e0822fa2990a56ad3576fbd96c1 100644
--- a/log/src/ana/iswitch2.c
+++ b/src/ana/iswitch2.c
@@ -25,7 +25,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 
 #define ISWITCH2_G
 #include "ana/iswitch2.h"
diff --git a/log/src/ana/main.c b/src/ana/main.c
similarity index 99%
rename from log/src/ana/main.c
rename to src/ana/main.c
index 2f6c0094ecb877881c084bf54214f2c64fe8d678..6d7aa65975969dc098c5db6dc2f19d7189e25e8c 100644
--- a/log/src/ana/main.c
+++ b/src/ana/main.c
@@ -27,14 +27,11 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 /*Version 1.5  Modular*/
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/nsolver.h"
 #include "ana/main.h"
 #include "node.h"
 
-#define newci_findprocedure  findprocedure
-extern int findprocedure (char *name, void (**start)());
-
 static void Update ();
 
 
@@ -1429,7 +1426,7 @@ log_krec *newkindptr;
     sprintf(Procname + strlen(Procname), "%c", newkindptr->proc[Index - 1]);
     Index++;
   }
-  if (!newci_findprocedure(Procname, (void(**) ())(&Initproc))) {
+  if (!findprocedure(Procname, (void(**) ())(&Initproc))) {
     AnaDummyInit(newkindptr);
     return;
   }
diff --git a/log/src/ana/mmeter.c b/src/ana/mmeter.c
similarity index 99%
rename from log/src/ana/mmeter.c
rename to src/ana/mmeter.c
index 3ab97899883befe59e92ad066e60d3844e2d7f14..8c8f21e04aadbb1b76fdf2fb73e8e92a46647789 100644
--- a/log/src/ana/mmeter.c
+++ b/src/ana/mmeter.c
@@ -25,7 +25,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/mmeter.h"
 #include "node.h"
 
diff --git a/log/src/ana/moscap.c b/src/ana/moscap.c
similarity index 99%
rename from log/src/ana/moscap.c
rename to src/ana/moscap.c
index 8e236cd62de29e56f22a39e90ba4e412dda8b2bc..12e9b6188036bd491982ff4c205a6528b5adba25 100644
--- a/log/src/ana/moscap.c
+++ b/src/ana/moscap.c
@@ -27,7 +27,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 /*When its time to add subthreshold light, look at IDIFF for new update,
   write procedures*/
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/moscap.h"
 #include "node.h"
 
diff --git a/log/src/ana/nfet4.c b/src/ana/nfet4.c
similarity index 99%
rename from log/src/ana/nfet4.c
rename to src/ana/nfet4.c
index f257389ad531c801200b288c5e5d6d8223ca36bc..bee234e13b6a5e0e6711e34a77a8bef0428ec832 100644
--- a/log/src/ana/nfet4.c
+++ b/src/ana/nfet4.c
@@ -26,7 +26,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/nfet4.h"
 #include "node.h"
 
diff --git a/log/src/ana/nfet5.c b/src/ana/nfet5.c
similarity index 99%
rename from log/src/ana/nfet5.c
rename to src/ana/nfet5.c
index 560006b05862621d2ec66fde8d66959516d3eb92..71f5bceb0c956d6b3da1e2966c145e8c36b42f31 100644
--- a/log/src/ana/nfet5.c
+++ b/src/ana/nfet5.c
@@ -25,7 +25,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/nfet5.h"
 #include "node.h"
 
diff --git a/log/src/ana/nfet7f.c b/src/ana/nfet7f.c
similarity index 99%
rename from log/src/ana/nfet7f.c
rename to src/ana/nfet7f.c
index 30bbbfc6d4db9a9133a23135cbc4e2b484dea21d..976277cdb50ee61e93510617072643d76e101869 100644
--- a/log/src/ana/nfet7f.c
+++ b/src/ana/nfet7f.c
@@ -25,7 +25,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/nfet7f.h"
 #include "node.h"
 
diff --git a/log/src/ana/nfet7t.c b/src/ana/nfet7t.c
similarity index 99%
rename from log/src/ana/nfet7t.c
rename to src/ana/nfet7t.c
index 8e44eb8e1550818d98b1bb9b1b9ff7de49148e94..aed1abdc2f9ec48f8f84371bd5769190978f0f42 100644
--- a/log/src/ana/nfet7t.c
+++ b/src/ana/nfet7t.c
@@ -25,7 +25,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/nfet7t.h"
 #include "node.h"
 
diff --git a/log/src/ana/npn1.c b/src/ana/npn1.c
similarity index 99%
rename from log/src/ana/npn1.c
rename to src/ana/npn1.c
index 859e48171f12082c5ecaeceda1ba3cd840e20c14..e586954e2b3506b9ed019f255bc7a898cbd29ae2 100644
--- a/log/src/ana/npn1.c
+++ b/src/ana/npn1.c
@@ -23,7 +23,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 /* Output from p2c, the Pascal-to-C translator */
 /* From input file "scott.text" */
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/npn1.h"
 #include "node.h"
 
diff --git a/log/src/ana/npn2.c b/src/ana/npn2.c
similarity index 99%
rename from log/src/ana/npn2.c
rename to src/ana/npn2.c
index adaa5c321bc99442dcbf3ed9df0fe319f86d63ea..c09b52ea578f5cda16bba27f38456a987681cbc4 100644
--- a/log/src/ana/npn2.c
+++ b/src/ana/npn2.c
@@ -23,7 +23,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 /* Output from p2c, the Pascal-to-C translator */
 /* From input file "scott.text" */
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/npn2.h"
 #include "node.h"
 
diff --git a/log/src/ana/nsolver.c b/src/ana/nsolver.c
similarity index 99%
rename from log/src/ana/nsolver.c
rename to src/ana/nsolver.c
index ace9e31d86b5b01e1f6e79368c7ed34002c2afb7..f961f064affcb2e68a51f08bd6dcf41f56dd23fe 100644
--- a/log/src/ana/nsolver.c
+++ b/src/ana/nsolver.c
@@ -66,7 +66,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 
 
 #include "ana/nsolver.h"
diff --git a/log/src/ana/nspc1.c b/src/ana/nspc1.c
similarity index 99%
rename from log/src/ana/nspc1.c
rename to src/ana/nspc1.c
index b6a910f8707a4e9919ebe1d6d0fbb0b3038761ad..2c8df81509961adc7784fa5974856844dec4730a 100644
--- a/log/src/ana/nspc1.c
+++ b/src/ana/nspc1.c
@@ -41,7 +41,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 /* From input file "swiss.text" */
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/nspc1.h"
 #include "node.h"
 
diff --git a/log/src/ana/numbers.c b/src/ana/numbers.c
similarity index 99%
rename from log/src/ana/numbers.c
rename to src/ana/numbers.c
index 10bb2630f06f30589a932cd64230e412c13f4a90..7426b1739bfe8e771fc189c4e9b464a57eb2963a 100644
--- a/log/src/ana/numbers.c
+++ b/src/ana/numbers.c
@@ -25,7 +25,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/numbers.h"
 
 
diff --git a/log/src/ana/pfet4.c b/src/ana/pfet4.c
similarity index 99%
rename from log/src/ana/pfet4.c
rename to src/ana/pfet4.c
index 6bb9cb63ba3a101d8d43c9b82454a344385e9fd2..7cb09eb603bcd2681085fa2d32b05a754c19a14c 100644
--- a/log/src/ana/pfet4.c
+++ b/src/ana/pfet4.c
@@ -24,7 +24,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 /* From input file "gates.text" */
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/pfet4.h"
 #include "node.h"
 
diff --git a/log/src/ana/pfet5.c b/src/ana/pfet5.c
similarity index 99%
rename from log/src/ana/pfet5.c
rename to src/ana/pfet5.c
index 5adcd25245401ad0c69518529d21d096004ad6dc..1144fb74e92c7c695aa31abc6348edb025452e3f 100644
--- a/log/src/ana/pfet5.c
+++ b/src/ana/pfet5.c
@@ -25,7 +25,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/pfet5.h"
 #include "node.h"
 
diff --git a/log/src/ana/pfet6.c b/src/ana/pfet6.c
similarity index 99%
rename from log/src/ana/pfet6.c
rename to src/ana/pfet6.c
index 5d1ffebe0820a5b4f08bdd9c0a45d4610480d8de..5d7bf45c1ee06fc81e624ba17d53f5d7680cca49 100644
--- a/log/src/ana/pfet6.c
+++ b/src/ana/pfet6.c
@@ -24,7 +24,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 /* From input file "swiss.text" */
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/pfet6.h"
 #include "node.h"
 
diff --git a/log/src/ana/pfet7f.c b/src/ana/pfet7f.c
similarity index 99%
rename from log/src/ana/pfet7f.c
rename to src/ana/pfet7f.c
index 2771912428224f6d7956c1a2b875b27f7225b66b..e954f4208f54df5388e83cfc0627d766371a9a1c 100644
--- a/log/src/ana/pfet7f.c
+++ b/src/ana/pfet7f.c
@@ -24,7 +24,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 /* From input file "swiss.text" */
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/pfet7f.h"
 #include "node.h"
 
diff --git a/log/src/ana/pfet7t.c b/src/ana/pfet7t.c
similarity index 99%
rename from log/src/ana/pfet7t.c
rename to src/ana/pfet7t.c
index 1aaa5a8c7647174daeab1f0aababf7d25e440805..696415b341e5de5c31b9dc40b393f3d55d647251 100644
--- a/log/src/ana/pfet7t.c
+++ b/src/ana/pfet7t.c
@@ -24,7 +24,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 /* From input file "swiss.text" */
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/pfet7t.h"
 #include "node.h"
 
diff --git a/log/src/ana/physical.c b/src/ana/physical.c
similarity index 99%
rename from log/src/ana/physical.c
rename to src/ana/physical.c
index c280ca0ba62b699cbc19de2bcf191d129fa59fdf..f80f3689f7b7369bd6ca659dc14fd8a9e011ce2d 100644
--- a/log/src/ana/physical.c
+++ b/src/ana/physical.c
@@ -23,7 +23,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 /* Output from p2c, the Pascal-to-C translator */
 /* From input file "tools.text" */
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/physical.h"
 
 #define N_k            1
diff --git a/log/src/ana/pnp1.c b/src/ana/pnp1.c
similarity index 99%
rename from log/src/ana/pnp1.c
rename to src/ana/pnp1.c
index 639ac24cb623f864d836e28883547c52f66795e8..8291ef9c1d8209537fa96a0b8d9ac51111fa6601 100644
--- a/log/src/ana/pnp1.c
+++ b/src/ana/pnp1.c
@@ -23,7 +23,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 /* Output from p2c, the Pascal-to-C translator */
 /* From input file "scott.text" */
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/pnp1.h"
 #include "node.h"
 
diff --git a/log/src/ana/pnp2.c b/src/ana/pnp2.c
similarity index 99%
rename from log/src/ana/pnp2.c
rename to src/ana/pnp2.c
index 9c25dde5b876995d9a1d5241eff4a134fb86c144..8f00d98cf04a519cbd0f45af5348a0c220f0c800 100644
--- a/log/src/ana/pnp2.c
+++ b/src/ana/pnp2.c
@@ -23,7 +23,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 /* Output from p2c, the Pascal-to-C translator */
 /* From input file "scott.text" */
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/pnp2.h"
 #include "node.h"
 
diff --git a/log/src/ana/pspc1.c b/src/ana/pspc1.c
similarity index 99%
rename from log/src/ana/pspc1.c
rename to src/ana/pspc1.c
index cfc8a4542b82690532a1ab8105a26f830f88e534..8a57e38f238209d3d6e5321b0199457413385b1e 100644
--- a/log/src/ana/pspc1.c
+++ b/src/ana/pspc1.c
@@ -42,7 +42,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 /* From input file "swiss.text" */
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/pspc1.h"
 #include "node.h"
 
diff --git a/log/src/ana/pwl.c b/src/ana/pwl.c
similarity index 99%
rename from log/src/ana/pwl.c
rename to src/ana/pwl.c
index d8b93f61bbd8ef100df4930837f4b68aef4aa131..c2e7e7a9de76d01ae8b7e4400026f77b4bc2e19c 100644
--- a/log/src/ana/pwl.c
+++ b/src/ana/pwl.c
@@ -79,7 +79,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 
 #include <math.h>
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 
 #define PWL_G
 #include "ana/pwl.h"
diff --git a/log/src/ana/resfloat.c b/src/ana/resfloat.c
similarity index 99%
rename from log/src/ana/resfloat.c
rename to src/ana/resfloat.c
index b13b33f565405c6c15d605aedb1fb10d3a9be67f..8406d65b425e022f788c7ecae91be7e432c540d2 100644
--- a/log/src/ana/resfloat.c
+++ b/src/ana/resfloat.c
@@ -26,7 +26,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/resfloat.h"
 #include "node.h"
 
diff --git a/log/src/ana/rtd.c b/src/ana/rtd.c
similarity index 99%
rename from log/src/ana/rtd.c
rename to src/ana/rtd.c
index 05aae14fc054dfbca73c08c4ba20944e7fa50c8f..e5b71b5fbf2a607c5b13b682e89d9196e16b88fc 100644
--- a/log/src/ana/rtd.c
+++ b/src/ana/rtd.c
@@ -55,7 +55,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
 #include <math.h>
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/rtd.h"
 #include "node.h"
 
diff --git a/log/src/ana/runspec.c b/src/ana/runspec.c
similarity index 99%
rename from log/src/ana/runspec.c
rename to src/ana/runspec.c
index f248ef1ae3370db73fb876e65ef9316c0512ba57..8e537da25b977a2f36320ee3738bd0cdf3f9576d 100644
--- a/log/src/ana/runspec.c
+++ b/src/ana/runspec.c
@@ -25,7 +25,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/runspec.h"
 
 #define N_fabrun       1
diff --git a/log/src/ana/stairs.c b/src/ana/stairs.c
similarity index 99%
rename from log/src/ana/stairs.c
rename to src/ana/stairs.c
index 300c31399fa3fa7b19425a1d726ee93459b906bd..ef00d4562d8f805e22a2d446264490b72f991832 100644
--- a/log/src/ana/stairs.c
+++ b/src/ana/stairs.c
@@ -25,7 +25,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/stairs.h"
 #include "node.h"
 
diff --git a/log/src/ana/tc.c b/src/ana/tc.c
similarity index 99%
rename from log/src/ana/tc.c
rename to src/ana/tc.c
index 2760f2af8df9489fe9b0039c47971fea237bf57f..89b3d4c4aae2ade59a8a086d2d8ed89002b58464 100644
--- a/log/src/ana/tc.c
+++ b/src/ana/tc.c
@@ -28,7 +28,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
   write procedures*/
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/tc.h"
 #include "node.h"
 
diff --git a/log/src/ana/thermal.c b/src/ana/thermal.c
similarity index 99%
rename from log/src/ana/thermal.c
rename to src/ana/thermal.c
index 842f3b03cad1adb04d3106424322f9529acdef41..78bc26a07bed35c561fb1a52e108639ac5de6611 100644
--- a/log/src/ana/thermal.c
+++ b/src/ana/thermal.c
@@ -25,7 +25,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/thermal.h"
 
 #define N_Kelvin       1
diff --git a/log/src/ana/vdiff.c b/src/ana/vdiff.c
similarity index 99%
rename from log/src/ana/vdiff.c
rename to src/ana/vdiff.c
index 22b115aba34aa44cf04d5a20567bdaf1b2db8cb4..a276ea508b7c8912d18166816684be52f3f03b14 100644
--- a/log/src/ana/vdiff.c
+++ b/src/ana/vdiff.c
@@ -25,7 +25,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/vdiff.h"
 #include "node.h"
 
diff --git a/log/src/ana/vswitch.c b/src/ana/vswitch.c
similarity index 99%
rename from log/src/ana/vswitch.c
rename to src/ana/vswitch.c
index 30fb322c439b95fbe86b2cacffef798e2e00d50c..e530697a6c96a3b17e1992fff66d16db1ac1075e 100644
--- a/log/src/ana/vswitch.c
+++ b/src/ana/vswitch.c
@@ -25,7 +25,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "ana/vswitch.h"
 #include "node.h"
 
diff --git a/log/src/diggates.c b/src/diggates.c
similarity index 99%
rename from log/src/diggates.c
rename to src/diggates.c
index ca1259fd9fbc024597c812ced87904623f032f70..89d214fd99c49908dd122b37a963b2a5584dad68 100644
--- a/log/src/diggates.c
+++ b/src/diggates.c
@@ -24,8 +24,8 @@
 /* Pascal module for SRAM8K and other gates */
 
 
-#include <p2c/p2c.h>
-#include <p2c/strings.h>
+#include <utils/p2c.h>
+#include <utils/strings.h>
 
 #include "mygates.h"
 
diff --git a/log/src/gate.c b/src/gate.c
similarity index 99%
rename from log/src/gate.c
rename to src/gate.c
index 76c4aabee0737cbb8b879dd650fa309473969962..cd632f4313994919388de8fd8e38243cca37553e 100644
--- a/log/src/gate.c
+++ b/src/gate.c
@@ -1,6 +1,6 @@
 
-#include <p2c/p2c.h>
-#include <p2c/newci.h>
+#include <utils/p2c.h>
+#include <graphics/newci.h>
 #include "logfont.h"
 #include "logglobals.h"
 #include "logstructs.h"
diff --git a/psys/src/mylib.c b/src/graphics/mylib.c
similarity index 99%
rename from psys/src/mylib.c
rename to src/graphics/mylib.c
index d05aa34b13045802a00a4eabd61f5ba8d5d08c02..e712c9280742899abbf91f0e9d3dee1b12a2d04c 100644
--- a/psys/src/mylib.c
+++ b/src/graphics/mylib.c
@@ -14,15 +14,13 @@
 #define __TYPES__
 
 #include <stdio.h>
-#ifdef HIRES
 #include <stdlib.h>
 #include <string.h>
-#endif  /* HIRES */
 #include <math.h>
 #include <time.h>
 
-#include <p2c/p2c.h>
-#include <p2c/mylib.h>
+#include <utils/p2c.h>
+#include <graphics/mylib.h>
 
 #include <X11/X.h>
 #include <X11/Xutil.h>
@@ -68,9 +66,9 @@ static void init_debug_flags()
   sync_all_calls = (getenv("SYNC_ALL_CALLS") != NULL);
 }
 
-extern void nc_refreshScreen (void);
-extern void nc_cursor_on (void);
-extern void nc_cursor_off (void);
+void nc_refreshScreen (void);
+void nc_cursor_on (void);
+void nc_cursor_off (void);
 
 #ifdef ENABLE_DEBUGGING
 # define Mfprintf show_all_mylib_calls && fprintf
@@ -93,8 +91,8 @@ extern void nc_cursor_off (void);
 /*  newcrt stuff  */
 #define nc_fontwidth 8
 #define nc_fontheight 13
-extern Window nc_window;
-extern int nc_initialized;
+Window nc_window;
+int nc_initialized;
 
 
 
@@ -442,7 +440,7 @@ void DisplayInitialize()
     char *getenv();
 #endif  /* HIRES */
     char *ep;
-    extern int nc_text_in_window;
+    int nc_text_in_window;
     char * m_usrfont;
 
     if (nc_text_in_window == 1 && (ep = getenv("AUTORAISE")) != NULL) {
diff --git a/psys/src/newci.c b/src/graphics/newci.c
similarity index 93%
rename from psys/src/newci.c
rename to src/graphics/newci.c
index 6b3c2d1508cf455eabefb35be96637dfefb97f83..b1384a9ffe98b0cde278c6410f987391edd087c1 100644
--- a/psys/src/newci.c
+++ b/src/graphics/newci.c
@@ -9,15 +9,15 @@
 
 #include <time.h>
 
-#include <p2c/p2c.h>
-#include <p2c/newci.h>
-#include <p2c/newcrt.h>
-#include <p2c/strings.h>
-#include <p2c/newasm.h>
-#include <p2c/sysdevs.h>
+#include <utils/p2c.h>
+#include <graphics/newci.h>
+#include <graphics/newcrt.h>
+#include <utils/strings.h>
+#include <utils/newasm.h>
+#include <utils/sysdevs.h>
 
 
-/*  This procedure should be made to do something real. */
+/*  This procedure should be made to do something real. <-- I agree. */
 void newci_inputstring(char *s)
 {
 	char buf[1024];
diff --git a/psys/src/newcrt.c b/src/graphics/newcrt.c
similarity index 98%
rename from psys/src/newcrt.c
rename to src/graphics/newcrt.c
index c71bc2d0b38eb875cffe3f568e67e04cd4d295bc..4ff471ddc728e439c27c439392d1815b39ce91ff 100644
--- a/psys/src/newcrt.c
+++ b/src/graphics/newcrt.c
@@ -1,3 +1,5 @@
+/* As the name suggests, this is probably a CRT emulator */
+/* Should be rewritten with ncurses, at least. */ 
 #define NEWCRT_G
 #define HIRES
 
@@ -6,12 +8,12 @@
 #include <stdarg.h>
 #include <signal.h>
 
-#include <p2c/p2c.h>
-#include <p2c/newcrt.h>
+#include <utils/p2c.h>
+#include <graphics/newcrt.h>
 
-#include <p2c/mylib.h>
+#include <graphics/mylib.h>
 
-#include <p2c/sysdevs.h>
+#include <utils/sysdevs.h>
 
 #include <X11/X.h>
 #include <X11/Xutil.h>
@@ -112,7 +114,7 @@ nc_windowRec *nc_lastLineWindow = &__nc_mainWindow;
 nc_windowRec *nc_statusWindow = &__nc_mainWindow;
 nc_windowRec *nc_defaultWindow = &__nc_mainWindow;
 
-extern XColor m_colors[ColorSets+1][ColorsInSet];    /*   From mylib   */
+XColor m_colors[ColorSets+1][ColorsInSet];    /*   From mylib   */
 static int colortrans[8] = {
 	m_green, m_yellow, m_black, m_red, m_cyan, m_white, m_blue, m_purple,
 };
@@ -285,7 +287,7 @@ void nc_setGraphics(int on_or_off)
 }
 
 
-extern void CheckRefresh();
+void CheckRefresh();
 
 void nc_putChar(int x, int y, int c)
 {
@@ -951,7 +953,6 @@ void nc_puts(char * s)
 }
 
 void nc_fputs(char * s, FILE *outfile)
-
 {
 	char printbuffer[2000];
 	char *p;
@@ -973,7 +974,6 @@ void nc_fputs(char * s, FILE *outfile)
 
 
 void nc_putchar(uchar c)
-
 {
 	char buffer[2];
 
@@ -1033,7 +1033,7 @@ void nc_cursor_off()
 }
 
 #pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"  // what the heck, :/
 
 char *nc_gets(char *buf)
 {
@@ -1085,10 +1085,7 @@ char *nc_gets(char *buf)
 
 #pragma clang diagnostic pop
 
-char *nc_fgets(s, n, stream)
-	char *s;
-	int n;
-	FILE *stream;
+char *nc_fgets(char *s, int n, FILE *stream)
 {
 	if (nc_text_in_window && (stream == stdin))
 		return(nc_gets(s));
@@ -1099,8 +1096,6 @@ char *nc_fgets(s, n, stream)
 }
 
 
-
-
 short nc_gType()
 {
 	return nc_g300;
diff --git a/psys/src/newkbd.c b/src/graphics/newkbd.c
similarity index 85%
rename from psys/src/newkbd.c
rename to src/graphics/newkbd.c
index ff2ad757b3c13c6e22c4f1e8bef486c4fe32b273..e4e73634bc51c05e462846d9b0fc91956c818dd9 100644
--- a/psys/src/newkbd.c
+++ b/src/graphics/newkbd.c
@@ -1,17 +1,17 @@
 #define NEWKBD_G
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 
 #ifndef NEWCRT_H
-#include <p2c/newcrt.h>
+#include <graphics/newcrt.h>
 #endif
 
 #ifndef NEWKBD_H
-#include <p2c/newkbd.h>
+#include <graphics/newkbd.h>
 #endif
 
 #ifndef MYLIB_H
-#include <p2c/mylib.h>
+#include <graphics/mylib.h>
 #endif
 
 #include <X11/Xlib.h>
@@ -147,8 +147,7 @@ static char *KeyNames[] = {
   "asciitilde",
 };
 
-extern void nk_ungetkey(c)
-uchar c;
+void nk_ungetkey(uchar c)
 {
   XEvent event;
   char buf[2];
@@ -162,18 +161,17 @@ uchar c;
   XPutBackEvent(m_display, &event);
 }
 
-extern void nk_keybufclear()
+void nk_keybufclear()
 {
   XEvent event;
 
-  while (XCheckTypedEvent(m_display, KeyPress, &event))
-    ;
+  while (XCheckTypedEvent(m_display, KeyPress, &event)) {
+		// noop
+	}
 }
 	 
 
-void nk_settransarray(mode, mat)
-int mode;
-nk_keytransinfo **mat;
+void nk_settransarray(int mode, nk_keytransinfo ** mat)
 {
   static int dummy;
 
diff --git a/log/src/label.c b/src/label.c
similarity index 99%
rename from log/src/label.c
rename to src/label.c
index c64c5d8ce7f764ba3b94ee63db78f1b62bb188b9..64fa9452b10979f624248309a30fadc57ed13558 100644
--- a/log/src/label.c
+++ b/src/label.c
@@ -1,8 +1,8 @@
 
 #include <string.h>
-#include <p2c/p2c.h>
-#include <p2c/strings.h>
-#include <p2c/newkbd.h>
+#include <utils/p2c.h>
+#include <utils/strings.h>
+#include <graphics/newkbd.h>
 #include "settings.h"
 #include "logglobals.h"
 #include "logfont.h"
diff --git a/psys/src/plot.font b/src/lib/plot.font
similarity index 100%
rename from psys/src/plot.font
rename to src/lib/plot.font
diff --git a/psys/src/texstuff.ps b/src/lib/texstuff.ps
similarity index 100%
rename from psys/src/texstuff.ps
rename to src/lib/texstuff.ps
diff --git a/psys/src/untilstuff.ps b/src/lib/untilstuff.ps
similarity index 100%
rename from psys/src/untilstuff.ps
rename to src/lib/untilstuff.ps
diff --git a/log/src/log.c b/src/log.c
similarity index 99%
rename from log/src/log.c
rename to src/log.c
index a812897eb75f45a57e1299ffde9025323a3d1b95..11e9ee2e86f48803b0642f9e171ff186a853dc8c 100644
--- a/log/src/log.c
+++ b/src/log.c
@@ -30,35 +30,35 @@
 
    David Gillespie
    */
-
+#define TOOL_KIND
 
 #include <unistd.h>
 #include <time.h>
+#include <stdlib.h>
 #include <string.h>
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 
 #include "logdef.h"
-#include <p2c/sysglobals.h>
-#include <p2c/sysdevs.h>
-#include <p2c/rnd.h>
+#include <utils/sysglobals.h>
+#include <utils/sysdevs.h>
 
 /*homeless orphans*/
 
-#include <p2c/misc.h>
+#include <utils/misc.h>
 #include "help.h"
-#include <p2c/newci.h>
-#include <p2c/filepack.h>
-#include <p2c/iodecl.h>
-#include <p2c/mylib.h>
+#include <graphics/newci.h>
+#include <utils/filepack.h>
+#include <utils/iodecl.h>
+#include <graphics/mylib.h>
 #include "logfont.h"
 #include "logstuff.h"
 #include "swap.h"
-#include <p2c/newkbd.h>
-#include <p2c/strings.h>
-#include <p2c/newasm.h>
-#include <p2c/newcrt.h>
+#include <graphics/newkbd.h>
+#include <utils/strings.h>
+#include <utils/newasm.h>
+#include <graphics/newcrt.h>
 
 /* @ home */
 #include "settings.h"
@@ -78,7 +78,6 @@
 #include "pagereader.h"
 
 char *GetChipmunkPath();
-int findprocedure (char *name, void (**start)());
 
 enum cursors;
 enum cursors cursortype;
@@ -1317,7 +1316,7 @@ void tracemessage(char *msg)
 			do
 			{
 				sprintf(tracefname, "/tmp/%.10s%03ld",
-					cuserid(NULL), P_rand(&gg.rndseed, 1000L));
+					cuserid(NULL), rand() % 1000L);
 
 			} while (access(tracefname, F_OK) == 0);
 		}
@@ -14113,7 +14112,6 @@ static void initialize()
 	gg.host = log_host_log;
 	gg.toolbase = NULL;
 	inithooks();
-	gg.rndseed = timers_sysclock();
 	gg.simstate = simst_null;
 	gg.simstatetool = NULL;
 	for (i = 0; i < maxgatesfiles; i++)
@@ -14593,6 +14591,7 @@ int main(int argc, char * argv[])
 
 	nc_text_in_window = 1;
 	PASCAL_MAIN(argc, argv);
+	srand(time(NULL));
 	tracefile = NULL;
 	dumpfile = NULL;
 	gg.initdone = false;
diff --git a/log/src/log.cnf b/src/log.cnf
similarity index 100%
rename from log/src/log.cnf
rename to src/log.cnf
diff --git a/log/src/log.gate b/src/log.gate
similarity index 100%
rename from log/src/log.gate
rename to src/log.gate
diff --git a/log/src/logcom.c b/src/logcom.c
similarity index 97%
rename from log/src/logcom.c
rename to src/logcom.c
index efbd55a3422c91497e6e8691b5a24384bc289753..50bfa2155ad9ee15698f7550f8ea8f43fa100231 100644
--- a/log/src/logcom.c
+++ b/src/logcom.c
@@ -33,27 +33,22 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 */
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "logdef.h"
-#include <p2c/sysglobals.h>
-#include <p2c/sysdevs.h>
-#include <p2c/rnd.h>
-#include <p2c/misc.h>
-#include <p2c/newci.h>
-#include <p2c/filepack.h>
-#include <p2c/iodecl.h>
-#include <p2c/mylib.h>
+#include <utils/sysglobals.h>
+#include <utils/sysdevs.h>
+#include <utils/misc.h>
+#include <graphics/newci.h>
+#include <utils/filepack.h>
+#include <utils/iodecl.h>
+#include <graphics/mylib.h>
 #include "logfont.h"
-#include <p2c/newkbd.h>
-#include <p2c/strings.h>
-#include <p2c/newasm.h>
-#include <p2c/newcrt.h>
+#include <graphics/newkbd.h>
+#include <utils/strings.h>
+#include <utils/newasm.h>
+#include <graphics/newcrt.h>
 #include "logcom.h"
 
-
-#define newci_findprocedure  findprocedure
-extern int findprocedure (char *name, void (**start)());
-
 #define attr_time       1
 #define attr_tstep      2
 #define attr_perf       3
@@ -686,7 +681,7 @@ log_action_t *act;
   case act_newkind:
     if (WITH->actkind->proc[0] != '\0') {
       proc_name_7(buf, WITH->actkind->proc);
-      if (*buf == '\0' || !newci_findprocedure(buf, (void(**) ())(&myproc)))
+      if (*buf == '\0' || !findprocedure(buf, (void(**) ())(&myproc)))
 	myproc = nullproc;
       i = 1;
       while (i <= numprocs_7 && myproc != procs_7[i])
diff --git a/log/src/logdef.c b/src/logdef.c
similarity index 98%
rename from log/src/logdef.c
rename to src/logdef.c
index 719438faff2de15d7bb7936e270af165d510029b..b2733c1c927b6a11a8af7b4caf7bab4865a97a64 100644
--- a/log/src/logdef.c
+++ b/src/logdef.c
@@ -31,7 +31,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 */
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 
 
 #define LOGDEF_G
diff --git a/log/src/logdig.c b/src/logdig.c
similarity index 98%
rename from log/src/logdig.c
rename to src/logdig.c
index b5314dd7960542929bdf7757f80d9b2ca6fa9102..aef4132a8305a5e74b52c69ddb2057e685a90122 100644
--- a/log/src/logdig.c
+++ b/src/logdig.c
@@ -36,7 +36,7 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 
 
 #define LOGDIG_G
diff --git a/log/src/loged.c b/src/loged.c
similarity index 99%
rename from log/src/loged.c
rename to src/loged.c
index 56954308b730152fdc4056426d48f67d54539da0..d673e6d9a3baffefb83b5ba2e0b49ffca3ed2ddf 100644
--- a/log/src/loged.c
+++ b/src/loged.c
@@ -44,29 +44,29 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 */
-
+#define SIM_KIND
 #include <unistd.h>
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
+#include <time.h>
+#include <stdlib.h>
 
 
 #include "logdef.h"
-#include <p2c/mylib.h>
-#include <p2c/newci.h>
-#include <p2c/newkbd.h>
-#include <p2c/strings.h>
-#include <p2c/newasm.h>
-#include <p2c/newcrt.h>
+#include <graphics/mylib.h>
+#include <graphics/newci.h>
+#include <graphics/newkbd.h>
+#include <utils/strings.h>
+#include <utils/newasm.h>
+#include <graphics/newcrt.h>
 
 #include "help.h"
 #include "swap.h"
 
-#include <p2c/filepack.h>
-#include <p2c/regex.h>
+#include <utils/filepack.h>
+#include <utils/regex.h>
 
 #include <string.h>
 
-#define newci_findprocedure2 findprocedure
-extern int findprocedure (char *name, void (**start)());
 extern short getshortsw(char *);
 
 
@@ -4498,7 +4498,7 @@ static void defcmd()
     return;
   }
   sprintf(name, "LOG_%d_PROC", kind.simtype);
-  if (!newci_findprocedure2(name, (void(**) ())(&proc))) {
+  if (!findprocedure(name, (void(**) ())(&proc))) {
     sprintf(STR1, "Simulator for type %d not loaded", kind.simtype);
     wrmsg(STR1);
     return;
@@ -5218,7 +5218,7 @@ long mode;
   if (kind->simtype == 0)
     return;
   sprintf(name, "LOG_%d_PROC", kind->simtype);
-  if (!newci_findprocedure2(name, (void(**) ())(&proc)))
+  if (!findprocedure(name, (void(**) ())(&proc)))
     return;
   gg.action = act_edit;
   gg.acttool = NULL;
@@ -5308,7 +5308,7 @@ static void dumpcmd()
   else {
     if (*argument == '\0') {
       do {
-	sprintf(argument, "/tmp/loged%ld.ps", P_rand());
+	sprintf(argument, "/tmp/loged%ld.ps", rand());
 	spool = 1;
       } while (access(argument, F_OK) == 0);
     } else
@@ -6488,7 +6488,7 @@ char *argument_;
   char argument[256], fn[256];
 
   strcpy(argument, argument_);
-  sprintf(fn, "/tmp/loged%03ld.text", P_rand());
+  sprintf(fn, "/tmp/loged%03ld.text", rand());
   if (*argument == '\0' && curkind != NULL)
     strcpy(argument, kind.name);
   writefile(fn, argument);
@@ -6723,6 +6723,7 @@ int main(int argc, char * argv[])
 
   nc_text_in_window = 1;
   PASCAL_MAIN(argc, argv);
+	srand(time(NULL));
 
   if (P_argc > 1 && !strcmp(P_argv[1], "-p")) {  /* piped mode */
     nc_text_in_window = 0;
@@ -6746,7 +6747,6 @@ int main(int argc, char * argv[])
   gg.resetflag = false;
   gg.pwrflag = false;
   gg.refrflag = false;
-  gg.rndseed = timers_sysclock();
   *gg.func = '\0';
   gg.time = 0.0;
   gg.simstate = simst_null;
diff --git a/log/src/loghier.c b/src/loghier.c
similarity index 99%
rename from log/src/loghier.c
rename to src/loghier.c
index a293d67afc63e44d90d090ab7016eb181ba6a0eb..155371738daa34ae6242767b597d075089d7bd66 100644
--- a/log/src/loghier.c
+++ b/src/loghier.c
@@ -30,8 +30,8 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 /* LOG hierarchy module           David Gillespie 1/7/89 */
 /* version for LOG 4.1 */
 
-#include <p2c/p2c.h>
-#include <p2c/strings.h>
+#include <utils/p2c.h>
+#include <utils/strings.h>
 #include "loghier.h"
 #include "node.h"
 
diff --git a/log/src/logntk.c b/src/logntk.c
similarity index 99%
rename from log/src/logntk.c
rename to src/logntk.c
index 1d83bed328c58f1e5290ea17fa84324a69bf7e71..db7b6950cce61ea314e569c6962adb85217da506 100644
--- a/log/src/logntk.c
+++ b/src/logntk.c
@@ -35,8 +35,8 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 /* Modified  7/27/88 to support digital hierarchy */
 
 #include <string.h>
-#include <p2c/p2c.h>
-#include <p2c/strings.h>
+#include <utils/p2c.h>
+#include <utils/strings.h>
 #include "logntk.h"
 #include "node.h"
 
diff --git a/log/src/logsim.c b/src/logsim.c
similarity index 99%
rename from log/src/logsim.c
rename to src/logsim.c
index 391eb8aa2574ce4e500e7ffbf4ad47e7f7869474..e7f50db82093d0f6384804d597455215347d5dc1 100644
--- a/log/src/logsim.c
+++ b/src/logsim.c
@@ -38,15 +38,11 @@
 /* $debug$ {*/
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
+#include <stdlib.h>
 #include "logsim.h"
 #include "node.h"
 
-
-#define newci_findprocedure  findprocedure
-extern int findprocedure (char *name, void (**start)());
-
-
 /*$ if debugging $
   $ debug on $
   $ end $*/
@@ -83,7 +79,7 @@ static const histcolortabletype histcolortable = {
 
 
 
-static long rndseed, newsystime, oldsystime, stabtime, resetcounter;
+static long newsystime, oldsystime, stabtime, resetcounter;
 static log_sigrec *vddsig, *gndsig, *resetsig;
 static int isstable, stabilizing, passready, maketimebid;
 static double nexttimebid;
@@ -1219,7 +1215,7 @@ static void tstep_16(log_16_action *act)
 		n = WITH->nbase;
 		while (n != NULL)
 		{
-			if (n->simtype == logsima_tool_16 && P_rand(&WITH->rndseed, 5L) == 0)
+			if (n->simtype == logsima_tool_16 && (rand() % 5L) == 0)
 			{
 				ni = (nodeinfo *)n->info;
 				ni->v = ni->v00;
@@ -1474,7 +1470,7 @@ static void setupkindproc(struct LOC_Log_16_proc *LINK)
 	procname[len] = '\0';
 	for (i = 0; i < len; i++)
 		procname[i] = WITH->proc[pc + i];
-	LINK->ki->hasproc = newci_findprocedure(procname,
+	LINK->ki->hasproc = findprocedure(procname,
 			(void(**) ())(&LINK->ki->kindproc));
 	if (!LINK->ki->hasproc)
 		LINK->ki->kindproc = log_16_noprog;
@@ -1520,7 +1516,6 @@ void Log_16_proc(log_action_t *lact)
 			if (*WITH->acttool->comment == '\0')
 				strcpy(WITH->acttool->comment, "Digital simulator");
 			logsima_init();
-			WITH->rndseed = timers_sysclock();
 			newsystime = 0;
 			vddsig = NULL;
 			gndsig = NULL;
diff --git a/log/src/logsima.c b/src/logsima.c
similarity index 100%
rename from log/src/logsima.c
rename to src/logsima.c
diff --git a/log/src/logsimasm.c b/src/logsimasm.c
similarity index 99%
rename from log/src/logsimasm.c
rename to src/logsimasm.c
index ead728fc5498cf381776490c07c295f110ca171d..ea3b25da69b4cf2417152a27c24d34550fd933c3 100644
--- a/log/src/logsimasm.c
+++ b/src/logsimasm.c
@@ -25,7 +25,7 @@
    Dave Gillespie, 3/27/90 */
 
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 
 #define LOGSIMA_G
 #include "logsima.h"
diff --git a/log/src/logsimed.c b/src/logsimed.c
similarity index 99%
rename from log/src/logsimed.c
rename to src/logsimed.c
index 0b93d6721673ea403b9a7fe285362621c5f673fa..bdbedd43df8f594aa056a1454399b9e24a2ff018 100644
--- a/log/src/logsimed.c
+++ b/src/logsimed.c
@@ -38,8 +38,8 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 /* $debug$ {*/
 
 #include <string.h>
-#include <p2c/p2c.h>
-#include <p2c/strings.h>
+#include <utils/p2c.h>
+#include <utils/strings.h>
 #include "logsimed.h"
 
 
diff --git a/log/src/logsimh.c b/src/logsimh.c
similarity index 99%
rename from log/src/logsimh.c
rename to src/logsimh.c
index 06cee91a0fb4949d58d16bd569ad4f96bfa17293..a93efd6cb626e9b71da046dd1e36fb7e87cbbb85 100644
--- a/log/src/logsimh.c
+++ b/src/logsimh.c
@@ -35,8 +35,8 @@
    */
 
 #include <string.h>
-#include <p2c/p2c.h>
-#include <p2c/strings.h>
+#include <utils/p2c.h>
+#include <utils/strings.h>
 #include "logsimh.h"
 #include "node.h"
 
@@ -4095,7 +4095,7 @@ static void dodump(struct LOC_compilepage *LINK)
 	char STR2[256];
 
 	f = NULL;
-	sprintf(buf, "/spool/apple.text/dig%ld", P_rand());
+	sprintf(buf, "/spool/apple.text/dig%ld", rand());
 	sprintf(STR2, "Writing to dump file %s", buf);
 	(*logsima_action.lact->hook.vmessage)(STR2);
 	if (f != NULL)
diff --git a/log/src/logspc.c b/src/logspc.c
similarity index 99%
rename from log/src/logspc.c
rename to src/logspc.c
index eaafe2c572a6071bb1dd2f53669e48b9f6564648..d2571fa04935f0267253890b100ace30d4812c00 100644
--- a/log/src/logspc.c
+++ b/src/logspc.c
@@ -80,7 +80,7 @@ Version		Date	Description
 
 /* Spice Globals */
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include "node.h"
 
 #define LOGSPC_VERSION "1.0 Beta"
@@ -135,8 +135,8 @@ char	pre_file[256] = "", post_file[256] = ""; /* for #include-esque stuff */
 /* End Of Spice Globals */
 
 #include <string.h>
-#include <p2c/p2c.h>
-#include <p2c/strings.h>
+#include <utils/p2c.h>
+#include <utils/strings.h>
 #include "logspc.h"
 
 extern double AnaVdd;
diff --git a/log/src/logstuff.c b/src/logstuff.c
similarity index 98%
rename from log/src/logstuff.c
rename to src/logstuff.c
index fc64a92578832e16c724c1df7dba01c042c825d3..86539f076088f89a9468b5e0df7a15794c339761 100644
--- a/log/src/logstuff.c
+++ b/src/logstuff.c
@@ -22,9 +22,9 @@ the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
 
 
 
-#include <p2c/p2c.h>
-#include <p2c/strings.h>
-#include <p2c/mylib.h>
+#include <utils/p2c.h>
+#include <utils/strings.h>
+#include <graphics/mylib.h>
 
 #include "logstuff.h"
 
diff --git a/log/src/node.c b/src/node.c
similarity index 99%
rename from log/src/node.c
rename to src/node.c
index 72123996d04e5194b12316bd6081d241286ad68b..494da7745f043c648a08b87ea58fdd014c2a5c70 100644
--- a/log/src/node.c
+++ b/src/node.c
@@ -1,6 +1,6 @@
 
-#include <p2c/p2c.h>
-#include <p2c/newkbd.h>
+#include <utils/p2c.h>
+#include <graphics/newkbd.h>
 #include "logglobals.h"
 #include "utils.h"
 #include "node.h"
diff --git a/log/src/page.c b/src/page.c
similarity index 98%
rename from log/src/page.c
rename to src/page.c
index 290153605c4274c92053449ce4aa89a4384fb43f..af5d307b4d966bf24e6c437264ce3ee687704632 100644
--- a/log/src/page.c
+++ b/src/page.c
@@ -1,6 +1,6 @@
 
-#include <p2c/p2c.h>
-#include <p2c/newkbd.h>
+#include <utils/p2c.h>
+#include <graphics/newkbd.h>
 #include "logglobals.h"
 #include "logfont.h"
 #include "utils.h"
diff --git a/log/src/pagereader.c b/src/pagereader.c
similarity index 100%
rename from log/src/pagereader.c
rename to src/pagereader.c
diff --git a/log/src/pagewriter.c b/src/pagewriter.c
similarity index 100%
rename from log/src/pagewriter.c
rename to src/pagewriter.c
diff --git a/log/src/screen.c b/src/screen.c
similarity index 99%
rename from log/src/screen.c
rename to src/screen.c
index db47f4e2723f8e043b644d0b1fbe244b16ba14d1..948f6984c22d188997321669ff7852cd18611cf9 100644
--- a/log/src/screen.c
+++ b/src/screen.c
@@ -30,9 +30,9 @@
    David Gillespie
    */
 
-#include <p2c/p2c.h>
-#include <p2c/newkbd.h>
-#include <p2c/newcrt.h>
+#include <utils/p2c.h>
+#include <graphics/newkbd.h>
+#include <graphics/newcrt.h>
 #include "logglobals.h"
 #include "logfont.h"
 #include "utils.h"
@@ -466,14 +466,14 @@ void addrabbit()
 	}
 	if (j == -1)
 	{
-		j = P_rand(&gg.rndseed, (long)rabtabsize) + 1;
+		j = (rand() % (long) rabtabsize) + 1;
 		m_bunny((long)rabtable[j - 1].x, (long)rabtable[j - 1].y);
 		rabtable[j - 1].next = 0;
 	}
 	do
 	{
-		rx = P_rand(&gg.rndseed, across - 24L);
-		ry = P_rand(&gg.rndseed, baseline - 40L) + down - baseline + 30;
+		rx = rand() % (across - 24L);
+		ry = (rand() % (baseline - 40L)) + down - baseline + 30;
 		nogood = false;
 		for (i = 0; i < rabtabsize; i++)
 		{
diff --git a/log/src/swap.c b/src/swap.c
similarity index 100%
rename from log/src/swap.c
rename to src/swap.c
diff --git a/log/src/tool.c b/src/tool.c
similarity index 95%
rename from log/src/tool.c
rename to src/tool.c
index 7f27ab34ccfedb888a3d8bf6901f99a05374aae5..8f3d2ac3085b5b1a7969eda677e26403d047d269 100644
--- a/log/src/tool.c
+++ b/src/tool.c
@@ -1,6 +1,6 @@
 
-#include <p2c/p2c.h>
-#include <p2c/newkbd.h>
+#include <utils/p2c.h>
+#include <graphics/newkbd.h>
 #include "logdef.h"
 #include "logglobals.h"
 #include "utils.h"
@@ -60,7 +60,7 @@ log_tool *findtool(char *name_)
 	if (!lp->ready)
 	{
 		sprintf(suffix, "LOG_%s_PROC", name);
-		ready = newci_findprocedure2(suffix, (void(**) ())(&proc));
+		ready = findprocedure(suffix, (void(**) ())(&proc));
 		if (gg.traceflag)
 			fprintf(tracefile, "Findtool to load: %s -  %s.\n", suffix, lp->fname);
 
@@ -75,7 +75,7 @@ log_tool *findtool(char *name_)
 			if (P_escapecode == -20)
 				_Escape(P_escapecode);
 			ENDTRY(try2);
-			ready = newci_findprocedure2(suffix, (void(**) ())(&proc));
+			ready = findprocedure(suffix, (void(**) ())(&proc));
 			if (gg.traceflag)
 				fprintf(tracefile, "Findtool, ready=%s\n", ready ? " TRUE" : "FALSE");
 		}
diff --git a/log/src/utils.c b/src/utils.c
similarity index 96%
rename from log/src/utils.c
rename to src/utils.c
index 4309e070b8f095a225558da191ac2006508f0934..e0d82a20283918c294c74faf9b6632419f245055 100644
--- a/log/src/utils.c
+++ b/src/utils.c
@@ -1,8 +1,8 @@
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 #include <stdlib.h>
 #include <ctype.h>
 #include <string.h>
-#include <p2c/strings.h>
+#include <utils/strings.h>
 #include "log.h"
 #include "logglobals.h"
 #include "utils.h"
diff --git a/psys/src/filepack.c b/src/utils/filepack.c
similarity index 87%
rename from psys/src/filepack.c
rename to src/utils/filepack.c
index 3597c859dff5cc196d5479aa15b9a053cc8d676b..c56982d64201ea0374eeb37709e287aad9051432 100644
--- a/psys/src/filepack.c
+++ b/src/utils/filepack.c
@@ -1,9 +1,9 @@
 #include <stdio.h>
 #include <math.h>
-#include <p2c/p2c.h>
-#include <p2c/filepack.h>
-#include <p2c/sysdevs.h>
-#include <p2c/sysglobals.h>
+#include <utils/p2c.h>
+#include <utils/filepack.h>
+#include <utils/sysdevs.h>
+#include <utils/sysglobals.h>
 
 void fp_change(char* filename1, char *filename2)
 {
diff --git a/src/utils/iodecl.c b/src/utils/iodecl.c
new file mode 100644
index 0000000000000000000000000000000000000000..2ac91c84e74c82d6e7e9d5f6c5d0383a44278a47
--- /dev/null
+++ b/src/utils/iodecl.c
@@ -0,0 +1,5 @@
+#define IODECLARATIONS_G
+
+#include <stdio.h>
+#include <utils/p2c.h>
+#include <utils/iodecl.h>
diff --git a/psys/src/misc.c b/src/utils/misc.c
similarity index 97%
rename from psys/src/misc.c
rename to src/utils/misc.c
index 89269ad393f4e16b7327bc0db7e0fb6a38b653a7..ab82e377129f6463d4734338d60e2c0647a4fb8b 100644
--- a/psys/src/misc.c
+++ b/src/utils/misc.c
@@ -2,8 +2,8 @@
 
 #include <stdio.h>
 #include <string.h>
-#include <p2c/p2c.h>
-#include <p2c/misc.h>
+#include <utils/p2c.h>
+#include <utils/misc.h>
 
 #ifndef LACK_GETPWNAM
 #include <pwd.h>
diff --git a/psys/src/newasmlib.c b/src/utils/newasm.c
similarity index 98%
rename from psys/src/newasmlib.c
rename to src/utils/newasm.c
index 727502c730bf2c15d27b0acc0ea5bdf790241eba..ca23ee55932722543b49f1f3f3dad43f4f9a30da 100644
--- a/psys/src/newasmlib.c
+++ b/src/utils/newasm.c
@@ -9,8 +9,8 @@
 
 # include <time.h>
 
-#include <p2c/p2c.h>
-#include <p2c/newasm.h>
+#include <utils/p2c.h>
+#include <utils/newasm.h>
 
 /* The following would benefit from assembly language if possible */
 
@@ -25,7 +25,7 @@
 #else
 # define ASR_L(v,n)   (((v) >= 0) ? ((v) >> (n)) : ~((~(v)) >> (n)))
 #endif
-#define VASR_L(v,n)   ((v) = ASR_L(v,n))
+
 
 /* Exchange two blocks of memory */
 void na_exch(long *s, long *d, long size)
diff --git a/psys/src/p2clib.c b/src/utils/p2c.c
similarity index 99%
rename from psys/src/p2clib.c
rename to src/utils/p2c.c
index 976805239ebd6994036af301bff92d6521e6585e..ef192cf05eaa4c763757a4ee2fdb569e299c0e75 100644
--- a/psys/src/p2clib.c
+++ b/src/utils/p2c.c
@@ -10,7 +10,7 @@
 
 #include <time.h>
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 
 
 int P_argc;
@@ -564,7 +564,7 @@ char *GetChipmunkPath(char *ev, char *deft)
     usleep -- support routine for 4.2BSD system call emulations
     last edit:  29-Oct-1984     D A Gwyn
 */
-//extern int select();
+//int select();
 
 int microsleep(long usec)         /* returns 0 if ok, else -1 */
 {
diff --git a/psys/src/regex.c b/src/utils/regex.c
similarity index 99%
rename from psys/src/regex.c
rename to src/utils/regex.c
index 552ff2d9bc1ab17aa23dd650092ab2ac180845b3..0d24072317332d3d6bd3b76d4f7b39a3f385eb12 100644
--- a/psys/src/regex.c
+++ b/src/utils/regex.c
@@ -1,11 +1,11 @@
 /* Regular expression search & replace */
 
-#include <p2c/p2c.h>
+#include <utils/p2c.h>
 
 
 #define REGEX_G
-#include <p2c/regex.h>
-#include <p2c/strings.h>
+#include <utils/regex.h>
+#include <utils/strings.h>
 
 
 #define checking        false
diff --git a/psys/src/strings.c b/src/utils/strings.c
similarity index 99%
rename from psys/src/strings.c
rename to src/utils/strings.c
index c6b00bd16c3f8249c30828b9f85915dfc9dc6bee..ef91bd91caf6bcd2c3c095e1f4d761dd18269786 100644
--- a/psys/src/strings.c
+++ b/src/utils/strings.c
@@ -1,5 +1,5 @@
-#include <p2c/p2c.h>
-#include <p2c/strings.h>
+#include <utils/p2c.h>
+#include <utils/strings.h>
 #include <time.h>
 
 void strsafeappend (char *s, char *s2)
diff --git a/psys/src/strlist.c b/src/utils/strlist.c
similarity index 98%
rename from psys/src/strlist.c
rename to src/utils/strlist.c
index 9e9c094c26fd75bf3416b952437a3cc1003498f4..6a198fcf166aa9537f1fb68cb61a4d3dd92dad24 100644
--- a/psys/src/strlist.c
+++ b/src/utils/strlist.c
@@ -1,5 +1,5 @@
-#include <p2c/p2c.h>
-#include <p2c/strlist.h>
+#include <utils/p2c.h>
+#include <utils/strlist.h>
 
 void strlist_init(strlist_t **base)
 {
diff --git a/psys/src/sysdevs.c b/src/utils/sysdevs.c
similarity index 78%
rename from psys/src/sysdevs.c
rename to src/utils/sysdevs.c
index 05ace0a87f2a5dd6ef3678f4688fcfd7277bd463..72298ec9fd90b4a310d2d7d256cb76cc9ebc52f2 100644
--- a/psys/src/sysdevs.c
+++ b/src/utils/sysdevs.c
@@ -3,16 +3,14 @@
 #include <time.h>
 #include <sys/time.h>
   
-#include <p2c/p2c.h>
-#include <p2c/sysglobals.h>
-#include <p2c/sysdevs.h>
+#include <utils/p2c.h>
+#include <utils/sysglobals.h>
+#include <utils/sysdevs.h>
 
 long sysclock()
 {
 	struct timeval tv;
-	struct timezone tz;
-
-	gettimeofday(&tv, &tz);
+	gettimeofday(&tv, NULL);
 	return tv.tv_sec % 86400 * 100 + tv.tv_usec / 10000;
 }
 
@@ -30,11 +28,10 @@ void sysdate(daterec *thedate)
 void systime(timerec *thetime)
 {
 	struct timeval tv;
-	struct timezone tz;
 	struct tm *t;
 	time_t temp;
 
-	gettimeofday(&tv, &tz);
+	gettimeofday(&tv, NULL);
 	temp = tv.tv_sec;
 	t = localtime(&temp);
 
diff --git a/log/src/wire.c b/src/wire.c
similarity index 99%
rename from log/src/wire.c
rename to src/wire.c
index 3cbe6a3b37441227cf5c08b88e51a9e8cdda3cfa..71d8c8fe658bc0260b15ad028a2e0a30dd11e6ca 100644
--- a/log/src/wire.c
+++ b/src/wire.c
@@ -1,6 +1,6 @@
 
-#include <p2c/p2c.h>
-#include <p2c/newkbd.h>
+#include <utils/p2c.h>
+#include <graphics/newkbd.h>
 #include "logglobals.h"
 #include "logdef.h"
 #include "utils.h"
diff --git a/log/tools/munch b/tools/munch
similarity index 95%
rename from log/tools/munch
rename to tools/munch
index 40a4269495a1a71606e6543b447771d53174340a..4be3f410411669ecadc44eda21ed672004dba677 100755
--- a/log/tools/munch
+++ b/tools/munch
@@ -9,7 +9,7 @@ shift
 
 nm $* > munch.temp
 
-echo '#include <p2c/p2c.h>'
+echo '#include <utils/p2c.h>'
 echo '#include "logstuff.h"'
 echo ''
 echo '/* Do not modify this file.  It is created automatically by "munch". */'