diff --git a/modules/src/em_opt/Makefile b/modules/src/em_opt/Makefile
index 1c9539ac2..cb013c08f 100644
--- a/modules/src/em_opt/Makefile
+++ b/modules/src/em_opt/Makefile
@@ -2,34 +2,45 @@
 EMHOME = ../../..
 INSTALL = $(EMHOME)/modules/install
 COMPARE = $(EMHOME)/modules/compare
-LIBOPT = libopt.a
+LIBDIR	= $(EMHOME)/modules/lib
+BINDIR	= $(EMHOME)/lib
+LIBOPT = libemopt.a
+
+# libraries required for standalone em_nopt
+INK	= $(LIBDIR)/libread_emk.a
+OUTK	= $(LIBDIR)/libemk.a
+SYS	= $(LIBDIR)/libsystem.a
+ALLOC	= $(LIBDIR)/liballoc.a $(LIBDIR)/malloc.o
+DATA	= $(EMHOME)/lib/em_data.a
+LIBS	= $(INK) $(OUTK) $(ALLOC) $(DATA) $(SYS)
 
 # set HOWMUCH to head -20 to limit number of patterns used
-#HOWMUCH = head -20
-HOWMUCH = cat
+#HOWMUCH= head -20
+HOWMUCH	= cat
+
+LEXLIB	= -ll
+INCLDIR	= -I$(EMHOME)/h -I$(EMHOME)/modules/h -I$(EMHOME)/modules/pkg
+PREFLAGS= $(INCLDIR) -DPRIVATE=static#	 -DDEBUG
 
-LEXLIB = -ll
-INCLDIR = -I$(EMHOME)/h -I$(EMHOME)/modules/h -I$(EMHOME)/modules/pkg
-PREFLAGS = $(INCLDIR) -DPRIVATE=static
 # Enable the next line to produce a version that output's the line number
 # from the patterns file each time an optimization is performed.
-#PREFLAG = $(PREFLAGS) -DSTATS
-PROFFLAG = -O
-CFLAGS = $(PREFLAGS) $(PROFFLAG)
-LLOPT =
-CMD = '$(CC) -c $(CFLAGS)'
+#PREFLAGS= $(PREFLAGS) -DSTATS
+PROFFLAG= -O
+CFLAGS	= $(PREFLAGS) $(PROFFLAG) -J
+LLOPT	=
+CMD	= '$(CC) -c $(CFLAGS)'
 
 .SUFFIXES:	.d .r
 
 .r.d:; CMD=$(CMD); export CMD; awk -f makefuns.awk $*.r | sh
 		touch $@
 
-CSRC = nopt.c aux.c mkcalls.c outputdfa.c outcalls.c\
+CSRC = main.c nopt.c mkstrct.c aux.c outputdfa.c outcalls.c\
 		findworst.c initlex.c
 
 SRCS = Makefile nopt.h parser.h parser.g syntax.l pseudo.r patterns $(CSRC)
 
-NOFILES = nopt.o dfa.o trans.o aux.o mkcalls.o
+NOFILES = nopt.o dfa.o trans.o aux.o
 
 POFILES = parser.o syntax.o outputdfa.o outcalls.o findworst.o initlex.o Lpars.o
 
@@ -37,10 +48,11 @@ GENFILES = Lpars.h Lpars.c parserdummy parser.c syntax.c dfadummy\
 		dfa.c dfa.c.save trans.c trans.c.save incalls.d incalls.r\
 		incalls.r.save pseudo.d
 
-all:		$(LIBOPT)
+all:		em_nopt $(LIBOPT)
 
 install:	all
 		$(INSTALL) lib/$(LIBOPT)
+		cp em_nopt $(BINDIR)
 
 cmp:		all
 		$(COMPARE) lib/$(LIBOPT)
@@ -52,13 +64,17 @@ opr:
 		make pr | opr
 
 clean:
-		rm -f C_*.o
-		rm -f C_*.c
-		rm -f $(NOFILES) $(POFILES) $(GENFILES) parser libopt.a
+		rm -f O_*.o
+		rm -f O_*.c
+		rm -f $(NOFILES) main.o mkstrct.o $(POFILES)
+		rm -f $(GENFILES) parser libopt.a
 
-$(LIBOPT):	dfadummy $(NOFILES) pseudo.d incalls.d
+em_nopt:	main.o $(NOFILES)
+		$(CC) -o em_nopt main.o $(NOFILES) $(LIBS)
+
+$(LIBOPT):	$(NOFILES) mkstrct.o pseudo.d incalls.d
 		rm -f $(LIBOPT)
-		ar rc $(LIBOPT) C_*.o $(NOFILES)
+		ar rc $(LIBOPT) O_*.o $(NOFILES) mkstrct.o
 		-sh -c 'ranlib $(LIBOPT)'
 
 dfadummy:	patterns parser
@@ -76,7 +92,6 @@ dfadummy:	patterns parser
 # How to build program to parse patterns table and build c files.
 
 PARSERLIB = $(EMHOME)/lib/em_data.a\
-		$(EMHOME)/modules/lib/libprint.a\
 		$(EMHOME)/modules/lib/liballoc.a\
 		$(EMHOME)/modules/lib/libstring.a\
 		$(EMHOME)/modules/lib/libsystem.a
@@ -88,13 +103,14 @@ parserdummy:	parser.g
 		LLgen $(LLOPT) parser.g
 		touch parserdummy
 
+main.o:		nopt.h
 nopt.o:		nopt.h
+mkstrct.o:	nopt.h
 aux.o:		nopt.h
-pseudo.d:	nopt.h
-mkcalls.o:	nopt.h
+pseudo.d:	nopt.h makefuns.awk
 dfa.o:		nopt.h dfadummy
 trans.o:	nopt.h dfadummy
-incalls.d:	nopt.h
+incalls.d:	nopt.h makefuns.awk
 incalls.r:	dfadummy
 
 parser.o:	Lpars.h parser.h
diff --git a/modules/src/em_opt/aux.c b/modules/src/em_opt/aux.c
index 2b85e16b0..8ed3e0b3d 100644
--- a/modules/src/em_opt/aux.c
+++ b/modules/src/em_opt/aux.c
@@ -1,4 +1,7 @@
-/* $Header$ */
+#ifndef NORCSID
+static char rcsid4[] = "$Header$";
+#endif
+
 #include "nopt.h"
 
 OO_rotate(w,amount)
@@ -21,8 +24,8 @@ OO_signsame(a,b)
 OO_sfit(val,nbits)
 	int val, nbits;
 {
-	long mask = 0;
-	int i;
+	register long mask = 0;
+	register int i;
 	for(i=nbits-1;i<8*sizeof(mask);i++)
 		mask |= (1<<i);
 	return(((val&mask) == 0) | (val&mask)==mask);
@@ -31,58 +34,62 @@ OO_sfit(val,nbits)
 OO_ufit(val, nbits)
 	int val, nbits;
 {
-	long mask = 0;
-	int i;
+	register long mask = 0;
+	register int i;
 	for(i=nbits;i<8*sizeof(mask);i++)
 		mask |= (1<<i);
 	return((val&mask) == 0);
 }
 
 OO_extsame(a1,a2)
-	struct instr *a1, *a2;
+	register p_instr a1, a2;
 {
-	if(a1->argtype != a2->argtype) return(0);
-	switch(a1->argtype) {
+	if (a1->em_argtype != a2->em_argtype)
+		return(0);
+	switch(a1->em_argtype) {
 	case cst_ptyp:
-		return(a1->acst == a2->acst);
+		return (a1->em_cst == a2->em_cst);
 	case sof_ptyp:
-		if(a1->asoff != a2->asoff) return(0);
-		return(strcmp(a1->adnam,a2->adnam)==0);
+		if(a1->em_off != a2->em_off)
+			return(0);
+		return (strcmp(a1->em_dnam,a2->em_dnam)==0);
 	case nof_ptyp:
-		if(a1->anoff != a2->anoff) return(0);
-		return(a1->adlb == a2->adlb);
+		if (a1->em_off != a2->em_off)
+			return(0);
+		return (a1->em_dlb == a2->em_dlb);
 	default:
-		fatal("illegal type (%d) to sameext!",a1->argtype);
+		fatal("illegal type (%d) to sameext!",a1->em_argtype);
 	}
 }
 
 OO_namsame(a1,a2)
-	struct instr *a1, *a2;
+	register p_instr a1, a2;
 {
-	if(a1->argtype != a2->argtype) return(0);
-	switch(a1->argtype) {
+	if (a1->em_argtype != a2->em_argtype)
+		return(0);
+	switch(a1->em_argtype) {
 	case cst_ptyp:
-		return(1);
+		return 1;
 	case sof_ptyp:
-		return(strcmp(a1->adnam,a2->adnam)==0);
+		return (strcmp(a1->em_dnam,a2->em_dnam)==0);
 	case nof_ptyp:
-		return(a1->adlb == a2->adlb);
+		return (a1->em_dlb == a2->em_dlb);
 	default:
-		fatal("illegal type (%d) to samenam!",a1->argtype);
+		fatal("illegal type (%d) to samenam!",a1->em_argtype);
 	}
 }
 
 OO_offset(a)
-	struct instr *a;
+	register p_instr a;
 {
-	switch(a->argtype) {
+	switch(a->em_argtype) {
 	case cst_ptyp:
-		return(a->acst);
+		return a->em_cst;
 	case sof_ptyp:
-		return(a->asoff);
+		return a->em_off;
 	case nof_ptyp:
-		return(a->anoff);
+		return a->em_off;
 	default:
-		fatal("illegal type (%d) to offset!",a->argtype);
+		fatal("illegal type (%d) to offset!",a->em_argtype);
 	}
 }
diff --git a/modules/src/em_opt/findworst.c b/modules/src/em_opt/findworst.c
index 065e73a89..cf310852f 100644
--- a/modules/src/em_opt/findworst.c
+++ b/modules/src/em_opt/findworst.c
@@ -1,5 +1,5 @@
 #ifndef NORCSID
-static char rcsid[] = "$Header$";
+static char rcsidp3[] = "$Header$";
 #endif
 
 #include "parser.h"
@@ -30,7 +30,7 @@ findworst(repl)
 	int s;
 	int mostbackups = 0;
 	if(n==0) {
-		fprint(ofile,"\t\t\tOO_backup(%d);\n", longestpattern-1);
+		fprintf(ofile,"\t\t\tOO_backup(%d);\n", longestpattern-1);
 		return;
 	}
 	for(s=1;s<=higheststate;s++) {
@@ -57,7 +57,7 @@ findworst(repl)
 		}
 	}
 	if(mostbackups)
-		fprint(ofile,"\t\t\tOO_backup(%d);\n",mostbackups);
+		fprintf(ofile,"\t\t\tOO_backup(%d);\n",mostbackups);
 }
 
 findfail(state)
@@ -85,12 +85,12 @@ findfail(state)
 				continue;
 			if((leftmatch(patterns[s],patterns[state],i,n)==1)&&
 				patterns[s].m_len==(n-i+1)) {
-				fprint(ofile,"\t{%d,%d,%d},",i-1,n-i+1,s);
+				fprintf(ofile,"\t{%d,%d,%d},",i-1,n-i+1,s);
 				return;
 			}
 		}
 	}
-	fprint(ofile,"\t{%d,0,0},",n);
+	fprintf(ofile,"\t{%d,0,0},",n);
 }
 
 PRIVATE int
diff --git a/modules/src/em_opt/initlex.c b/modules/src/em_opt/initlex.c
index ef05d206b..933762650 100644
--- a/modules/src/em_opt/initlex.c
+++ b/modules/src/em_opt/initlex.c
@@ -1,5 +1,5 @@
 #ifndef NORCSID
-static char rcsid[] = "$Header$";
+static char rcsidp2[] = "$Header$";
 #endif
 
 #include <em_mnem.h>
diff --git a/modules/src/em_opt/main.c b/modules/src/em_opt/main.c
new file mode 100644
index 000000000..48e711719
--- /dev/null
+++ b/modules/src/em_opt/main.c
@@ -0,0 +1,102 @@
+/*
+ * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
+ * See the copyright notice in the ACK home directory, in the file "Copyright".
+ */
+#ifndef NORCSID
+static char rcsid1[] = "$Header$";
+#endif
+
+/*	This is the main program for the stand-alone version of the
+	peephole optimizer.
+*/
+
+#include	"nopt.h"
+
+char *filename;			/* Name of input file */
+int errors;			/* Number of errors */
+
+main(argc,argv)
+	char **argv;
+{
+	register p_instr p = GETINSTR();
+
+	if (argc >= 2) {
+		filename = argv[1];
+	}
+	else	filename = 0;
+	if (!EM_open(filename)) {
+		fatal(EM_error);
+	}
+	EM_getinstr(p);
+	O_init((arith) EM_wordsize, (arith) EM_pointersize);
+	if (argc >= 3) {
+		if (!O_open(argv[2])) {
+			fatal("O_open failed");
+		}
+	}
+	else	if (!O_open( (char *) 0)) fatal("O_open failed");
+	O_magic();
+	for(;;) {
+		switch(p->em_type) {
+		case EM_DEFILB:
+			*OO_nxtpatt++ = p;
+			OO_dfa(p->em_opcode=op_lab);
+			break;
+		case EM_MNEM:
+			switch(p->em_argtype) {
+			case sof_ptyp:
+				p->em_dnam = OO_freestr(p->em_dnam);
+				break;
+			case pro_ptyp:
+				p->em_pnam = OO_freestr(p->em_pnam);
+				break;
+			case str_ptyp:
+			case ico_ptyp:
+			case uco_ptyp:
+			case fco_ptyp:
+				p->em_string = OO_freestr(p->em_string);
+				break;
+			}
+			*OO_nxtpatt++ = p;
+			OO_dfa(p->em_opcode);
+			break;
+		default:
+			FLUSHDFA();
+			EM_mkcalls(p);
+			break;
+		case EM_EOF:
+			goto got_eof;
+		case EM_ERROR:
+			error("%s", EM_error);
+			break;
+		case EM_FATAL:
+			fatal("%s", EM_error);
+		}
+		EM_getinstr(p=GETINSTR());
+	}
+ got_eof:
+	O_close();
+	EM_close();
+	exit(errors);
+}
+
+/* VARARGS */
+error(s,a1,a2,a3,a4)
+	char *s;
+{
+	fprintf(stderr,
+		"%s, line %d: ",
+		filename ? filename : "standard input",
+		EM_lineno);
+	fprintf(stderr,s,a1,a2,a3,a4);
+	fprintf(stderr, "\n");
+	errors++;
+}
+
+/* VARARGS */
+fatal(s,a1,a2,a3,a4)
+	char *s;
+{
+	error(s,a1,a2,a3,a4);
+	exit(1);
+}
diff --git a/modules/src/em_opt/makefuns.awk b/modules/src/em_opt/makefuns.awk
index e140fdaf4..a7b175fea 100644
--- a/modules/src/em_opt/makefuns.awk
+++ b/modules/src/em_opt/makefuns.awk
@@ -9,16 +9,16 @@ BEGIN		{
 		if(seenproc) {
 			print "}"
 			print "--EOF--"
-			printf "if %s C_%s.c\n",CC,nam
+			printf "if %s O_%s.c\n",CC,nam
 			printf "then :\nelse exit 1\nfi\n"
-			printf "rm -f C_%s.c\n",nam
+			printf "rm -f O_%s.c\n",nam
 		}
 		seenproc = 1
 		$1 = substr($1,1,index($1,"\t")-1);
 		nam = $1
-		printf "cat > C_%s.c << '--EOF--'\n",$1
+		printf "cat > O_%s.c << '--EOF--'\n",$1
 		print "#include \"nopt.h\""
-		printf "C_%s(",$1
+		printf "O_%s(",$1
 		nparms = split($2,parms,":");
 		for(p=1;p<nparms;p++) {
 			if(p!=1) {
@@ -52,8 +52,8 @@ END		{
 		if(seenproc) {
 			print "}"
 			print "--EOF--"
-			printf "if %s C_%s.c\n",CC,nam
+			printf "if %s O_%s.c\n",CC,nam
 			printf "then :\nelse exit 1\nfi\n"
-			printf "rm -f C_%s.c\n",nam
+			printf "rm -f O_%s.c\n",nam
 		}
 		}
diff --git a/modules/src/em_opt/mkstrct.c b/modules/src/em_opt/mkstrct.c
new file mode 100644
index 000000000..7235a248c
--- /dev/null
+++ b/modules/src/em_opt/mkstrct.c
@@ -0,0 +1,90 @@
+#ifndef NORCSID
+static char rcsid3[] = "$Header$";
+#endif
+
+#include "nopt.h"
+
+OO_inop(opcode)
+	int opcode;
+{
+	register p_instr p = GETINSTR();
+	p->em_type = EM_MNEM;
+	p->em_opcode = opcode;
+	p->em_argtype = 0;
+	*OO_nxtpatt++ = p;
+}
+
+OO_incst(opcode,cst)
+	int opcode,cst;
+{
+	register p_instr p = GETINSTR();
+	p->em_type = EM_MNEM;
+	p->em_opcode = opcode;
+	p->em_argtype = cst_ptyp;
+	p->em_cst = cst;
+	*OO_nxtpatt++ = p;
+}
+
+OO_inlab(opcode,lab)
+	int opcode,lab;
+{
+	register p_instr p = GETINSTR();
+	p->em_type = EM_MNEM;
+	p->em_opcode = opcode;
+	p->em_argtype = ilb_ptyp;
+	p->em_ilb = lab;
+	*OO_nxtpatt++ = p;
+}
+
+OO_inpnam(opcode,pnam)
+	int opcode;
+	char *pnam;
+{
+	register p_instr p = GETINSTR();
+	p->em_type = EM_MNEM;
+	p->em_opcode = opcode;
+	p->em_argtype = pro_ptyp;
+	p->em_pnam = OO_freestr(pnam);
+	*OO_nxtpatt++ = p;
+}
+
+OO_indefilb(opcode,deflb)
+	int opcode;
+	label deflb;
+{
+	register p_instr p = GETINSTR();
+	p->em_type = EM_DEFILB;
+	p->em_opcode = opcode;
+	p->em_argtype = 0;
+	p->em_ilb = deflb;
+	*OO_nxtpatt++ = p;
+}
+
+OO_indnam(opcode,name,off)
+	int opcode;
+	char *name;
+	int off;
+{
+	register p_instr p = GETINSTR();
+	p->em_type = EM_MNEM;
+	p->em_opcode = opcode;
+	p->em_argtype = sof_ptyp;
+        p->em_dnam = OO_freestr(name);
+	p->em_off = off;
+	*OO_nxtpatt++ = p;
+}
+
+OO_indlb(opcode,lab,off)
+	int opcode;
+	label lab;
+	int off;
+{
+	register p_instr p = GETINSTR();
+	p->em_type = EM_MNEM;
+	p->em_opcode = opcode;
+	p->em_argtype = nof_ptyp;
+	p->em_dlb = lab;
+	p->em_off = off;
+	*OO_nxtpatt++ = p;
+}
+
diff --git a/modules/src/em_opt/nopt.c b/modules/src/em_opt/nopt.c
index 636d3a297..cb8a27bff 100644
--- a/modules/src/em_opt/nopt.c
+++ b/modules/src/em_opt/nopt.c
@@ -1,68 +1,67 @@
 #ifndef NORCSID
-static char rcsid[] = "$Header$";
+static char rcsid2[] = "$Header$";
 #endif
 
 #include "nopt.h"
-extern int maxpattern;	/* Initialized from patterns in dfa.c */
+extern int OO_maxpattern;	/* Initialized from patterns in dfa.c */
 #define MAXBACKUP	50
 #define MAXOUTPUT	200
 #define MAXFREEI	200
 #define MAXSTRING	1000
 
-#define GETINSTR() (nextifree>freeiqueue)?*(--nextifree):\
-	((struct instr *)Malloc(sizeof(struct instr)))
+extern char	em_mnem[][4];
+extern char	em_pseu[][4];
 
-extern char em_mnem[][4];
+p_instr		*OO_freeiqueue;
+p_instr		*OO_nxtifree;
+p_instr		*OO_patternqueue;
+p_instr		*OO_nxtpatt;
+p_instr		*OO_bkupqueue;
+p_instr		*OO_nxtbackup;
+p_instr		OO_OTHER;
 
-struct instr **OO_patternqueue;
-struct instr **OO_nxtpatt;
-struct instr **OO_bkupqueue;
-struct instr **OO_nxtbackup;
+static char	*filename;
+static p_instr	*lastbackup;
+static p_instr	*outputqueue;
+static p_instr	*nextoutput;
+static p_instr	*lastoutput;
+static p_instr	*lastifree;
+static char	*strqueue;
+static char	*nextstr;
+static char	*laststr;
 
-static char *filename;
-static struct instr **lastbackup;
-static struct instr **outputqueue;
-static struct instr **nextoutput;
-static struct instr **lastoutput;
-static struct instr **freeiqueue;
-static struct instr **nextifree;
-static struct instr **lastifree;
-static char *strqueue;
-static char *nextstr;
-static char *laststr;
-
-int OO_noutput;	/* number of instructions in output queue */
-int OO_WSIZE;	/* wordlength */
-int OO_PSIZE;	/* pointer length */
+int		OO_noutput;	/* number of instructions in output queue */
+int		OO_WSIZE;	/* wordlength */
+int		OO_PSIZE;	/* pointer length */
 
 #ifdef STATS
-int OO_wrstats = 1;			/* pattern statistics output */
+int		OO_wrstats = 1;	/* pattern statistics output */
 #endif
 
-C_init(wsize,psize)
+O_init(wsize,psize)
 	arith wsize, psize;
 {
 	allocmem();
-	O_init(wsize,psize);
+	C_init(wsize,psize);
 	OO_WSIZE = wsize;
 	OO_PSIZE = psize;
 }
 
-C_open(fname)
+O_open(fname)
 	char *fname;
 {
 	filename = fname;
-	return(O_open(fname));
+	return(C_open(fname));
 }
 
-C_magic()
+O_magic()
 {
-	O_magic();
+	C_magic();
 }
 
-C_close()
+O_close()
 {
-	O_close();
+	C_close();
 }
 
 PRIVATE
@@ -70,9 +69,9 @@ fatal(s,a)
 	char *s;
 	int a;
 {
-	fprint(STDERR, "%s: ", filename ? filename : "standard input");
-	fprint(STDERR,s,a);
-	fprint(STDERR,"\n");
+	fprintf(stderr, "%s: ", filename ? filename : "standard input");
+	fprintf(stderr,s,a);
+	fprintf(stderr,"\n");
 	sys_stop(S_EXIT);
 }
 
@@ -81,48 +80,65 @@ allocmem()
 {
 	/* Allocate memory for queues on heap */
 	OO_nxtpatt = OO_patternqueue =
-		(struct instr **)Malloc(maxpattern*sizeof(struct instr *));
+		(p_instr *)Malloc(OO_maxpattern*sizeof(p_instr));
 	OO_nxtbackup = OO_bkupqueue =
-		(struct instr **)Malloc(MAXBACKUP*sizeof(struct instr *));
+		(p_instr *)Malloc(MAXBACKUP*sizeof(p_instr));
 	lastbackup = OO_bkupqueue + MAXBACKUP - 1;
 	nextoutput = outputqueue =
-		(struct instr **)Malloc(MAXOUTPUT*sizeof(struct instr *));
+		(p_instr *)Malloc(MAXOUTPUT*sizeof(p_instr));
 	lastoutput = outputqueue + MAXOUTPUT - 1;
 	OO_noutput = 0;
-	nextifree = freeiqueue =
-		(struct instr **)Malloc(MAXFREEI*sizeof(struct instr *));
-	lastifree = freeiqueue + MAXFREEI - 1;
+	OO_nxtifree = OO_freeiqueue =
+		(p_instr *)Malloc(MAXFREEI*sizeof(p_instr));
+	lastifree = OO_freeiqueue + MAXFREEI - 1;
 	nextstr = strqueue =
 		(char *)Malloc(MAXSTRING*sizeof(char));
 	laststr = strqueue + MAXSTRING - 1;
+	/* allocate dummy OTHER data structure */
+	OO_OTHER = (p_instr)Malloc(sizeof(struct e_instr));
+	OO_OTHER->em_type = EM_MNEM;
+	OO_OTHER->em_opcode = OTHER;
+	OO_OTHER->em_argtype = 0;
 }
 
 OO_free(p)
-	struct instr *p;
+	p_instr	p;
 {
-	if(nextifree > lastifree) {
+	if(OO_nxtifree > lastifree) {
 #ifdef DEBUG
-		fprint(STDERR,"Warning: Overflow of free intr. queue.\n");
-		fprint(STDERR,"Ignored free of ");
+		fprintf(stderr,"Warning: Overflow of free intr. queue.\n");
+		fprintf(stderr,"Ignored free of ");
 		prtinst(p);
-		fprint(STDERR,"\n");
+		fprintf(stderr,"\n");
 		printstate("Freea overflow");
 #endif
 		return;
 	}
-	*nextifree++ = p;
+	*OO_nxtifree++ = p;
 }
 
-PRIVATE char *
-freestr(s)
-	char *s;
+char *
+OO_freestr(str)
+	char *str;
 {
-	char *res = nextstr;
-	while(*nextstr++ = *s++);
-	if(nextstr > laststr) {
-		fprint(STDERR,"string space overflowed!\n");
-		sys_stop(S_EXIT);
+	register char *s = str;
+	register char *res;
+	while (*s++);
+ again:
+	if ((s-str) > (laststr-nextstr)) {
+		unsigned newsize = (laststr - strqueue + 1)*2;
+		res = Realloc(strqueue,newsize);
+		laststr = res + newsize - 1;
+		nextstr = res + (nextstr - strqueue);
+		strqueue = res;
+#ifdef DEBUG
+		fprintf(stderr,"Warning: Reallocated string area.");
+		fprintf(stderr,"New size is %d bytes\n", newsize);
+#endif
+		goto again;
 	}
+	res=nextstr;
+	for(s=str;*nextstr++ = *s++;);
 	return(res);
 }
 
@@ -132,13 +148,14 @@ OO_flush()
 	/* Output all instructions waiting in the output queue and free their
 	/* storage including the saved strings.
 	*/
-	struct instr **p;
+	register int n;
+	register p_instr *p;
 #ifdef DEBUG
 	printstate("Flush");
 #endif
-	if(OO_noutput) {
-		for(p=outputqueue;p<nextoutput;p++) {
-			OO_mkcalls(*p);
+	if (n = OO_noutput) {
+		for(p=outputqueue;n--;p++) {
+			EM_mkcalls(*p);
 			OO_free(*p);
 		}
 		nextoutput=outputqueue;
@@ -148,166 +165,13 @@ OO_flush()
 	}
 }
 
-OO_outop(opcode)
-	int opcode;
-{
-	register struct instr *p = GETINSTR();
-	p->opcode = opcode;
-	p->argtype = none_ptyp;
-	OO_out(p);
-}
-
-OO_inop(opcode)
-	int opcode;
-{
-	register struct instr *p = GETINSTR();
-	p->opcode = opcode;
-	p->argtype = none_ptyp;
-	*OO_nxtpatt++ = p;
-}
-
-OO_outcst(opcode,cst)
-	int opcode,cst;
-{
-	register struct instr *p = GETINSTR();
-	p->opcode = opcode;
-	p->argtype = cst_ptyp;
-	p->acst = cst;
-	OO_out(p);
-}
-
-OO_incst(opcode,cst)
-	int opcode,cst;
-{
-	register struct instr *p = GETINSTR();
-	p->opcode = opcode;
-	p->argtype = cst_ptyp;
-	p->acst = cst;
-	*OO_nxtpatt++ = p;
-}
-
-OO_outlab(opcode,lab)
-	int opcode,lab;
-{
-	register struct instr *p = GETINSTR();
-	p->opcode = opcode;
-	p->argtype = cst_ptyp;
-	p->acst = lab;
-	OO_out(p);
-}
-
-OO_inlab(opcode,lab)
-	int opcode,lab;
-{
-	register struct instr *p = GETINSTR();
-	p->opcode = opcode;
-	p->argtype = cst_ptyp;
-	p->acst = lab;
-	*OO_nxtpatt++ = p;
-}
-
-OO_outpnam(opcode,pnam)
-	int opcode;
-	char *pnam;
-{
-	register struct instr *p = GETINSTR();
-	p->opcode = opcode;
-	p->argtype = pro_ptyp;
-	p->apnam = pnam;
-	OO_out(p);
-}
-
-OO_inpnam(opcode,pnam)
-	int opcode;
-	char *pnam;
-{
-	register struct instr *p = GETINSTR();
-	p->opcode = opcode;
-	p->argtype = pro_ptyp;
-	p->apnam = freestr(pnam);
-	*OO_nxtpatt++ = p;
-}
-
-OO_outdefilb(opcode,deflb)
-	int opcode;
-	label deflb;
-{
-	register struct instr *p = GETINSTR();
-	p->opcode = opcode;
-	p->argtype = lab_ptyp;
-	p->alab = deflb;
-	OO_out(p);
-}
-
-OO_indefilb(opcode,deflb)
-	int opcode;
-	label deflb;
-{
-	register struct instr *p = GETINSTR();
-	p->opcode = opcode;
-	p->argtype = lab_ptyp;
-	p->alab = deflb;
-	*OO_nxtpatt++ = p;
-}
-
-OO_outext(opcode,arg,soff)
-	int opcode;
-	struct instr *arg;
-	int soff;
-{
-	register struct instr *p = GETINSTR();
-	p->opcode = opcode;
-	switch(p->argtype = arg->argtype) {
-	case cst_ptyp:
-		p->acst = soff;
-		break;
-	case sof_ptyp:
-		p->adnam = arg->adnam;
-		p->asoff = soff;
-		break;
-	case nof_ptyp:
-		p->adlb = arg->adlb;
-		p->anoff = soff;
-		break;
-	default:
-		fatal("Unexpected type %d in outext",arg->argtype);
-	}
-	OO_out(p);
-}
-
-OO_indnam(opcode,name,off)
-	int opcode;
-	char *name;
-	int off;
-{
-	register struct instr *p = GETINSTR();
-	p->opcode = opcode;
-	p->argtype = sof_ptyp;
-	p->adnam = freestr(name);
-	p->asoff = off;
-	*OO_nxtpatt++ = p;
-}
-
-OO_indlb(opcode,lab,off)
-	int opcode;
-	label lab;
-	int off;
-{
-	register struct instr *p = GETINSTR();
-	p->opcode = opcode;
-	p->argtype = nof_ptyp;
-	p->adlb = lab;
-	p->anoff = off;
-	*OO_nxtpatt++ = p;
-}
-
 OO_out(p)
-	struct instr *p;
+	p_instr	p;
 {
 	/* Put the instruction p on the output queue */
 	if(nextoutput > lastoutput) {
 #ifdef DEBUG
-		fprint(STDERR,"Warning: Overflow of outputqueue - output flushed\n");
+		fprintf(stderr,"Warning: Overflow of outputqueue - output flushed\n");
 #endif
 		OO_flush();
 	}
@@ -315,13 +179,95 @@ OO_out(p)
 	*nextoutput++ = p;
 }
 
+OO_outop(opcode)
+	int opcode;
+{
+	register p_instr p = GETINSTR();
+	p->em_type = EM_MNEM;
+	p->em_opcode = opcode;
+	p->em_argtype = 0;
+	OO_out(p);
+}
+
+OO_outcst(opcode,cst)
+	int opcode,cst;
+{
+	register p_instr p = GETINSTR();
+	p->em_type = EM_MNEM;
+	p->em_opcode = opcode;
+	p->em_argtype = cst_ptyp;
+	p->em_cst = cst;
+	OO_out(p);
+}
+
+OO_outlab(opcode,lab)
+	int opcode,lab;
+{
+	register p_instr p = GETINSTR();
+	p->em_type = EM_MNEM;
+	p->em_opcode = opcode;
+	p->em_argtype = ilb_ptyp;
+	p->em_ilb = lab;
+	OO_out(p);
+}
+
+OO_outpnam(opcode,pnam)
+	int opcode;
+	char *pnam;
+{
+	register p_instr p = GETINSTR();
+	p->em_type = EM_MNEM;
+	p->em_opcode = opcode;
+	p->em_argtype = pro_ptyp;
+	p->em_pnam = pnam;
+	OO_out(p);
+}
+
+OO_outdefilb(opcode,deflb)
+	int opcode;
+	label deflb;
+{
+	register p_instr p = GETINSTR();
+	p->em_type = EM_DEFILB;
+	p->em_opcode = opcode;
+	p->em_argtype = 0;
+	p->em_ilb = deflb;
+	OO_out(p);
+}
+
+OO_outext(opcode,arg,off)
+	int opcode;
+	p_instr	arg;
+	int off;
+{
+	register p_instr p = GETINSTR();
+	p->em_type = EM_MNEM;
+	p->em_opcode = opcode;
+	switch(p->em_argtype = arg->em_argtype) {
+	case cst_ptyp:
+		p->em_cst = off;
+		break;
+	case sof_ptyp:
+		p->em_dnam = arg->em_dnam;
+		p->em_off = off;
+		break;
+	case nof_ptyp:
+		p->em_dlb = arg->em_dlb;
+		p->em_off = off;
+		break;
+	default:
+		fatal("Unexpected type %d in outext",arg->em_argtype);
+	}
+	OO_out(p);
+}
+
 OO_pushback(p)
-	struct instr *p;
+	p_instr	p;
 {
 	/* push instr. p onto bkupqueue */
 	if(OO_nxtbackup > lastbackup) {
 #ifdef DEBUG
-		fprint(STDERR,"Warning: Overflow of bkupqueue-backup ignored\n");
+		fprintf(stderr,"Warning: Overflow of bkupqueue-backup ignored\n");
 		printstate("Backup overflow");
 #endif
 		return;
@@ -330,7 +276,7 @@ OO_pushback(p)
 }
 
 OO_backup(n)
-	int n;
+	register int n;
 {
 	/* copy (up to) n instructions from output to backup queues */
 	while(n-- && nextoutput>outputqueue) {
@@ -340,9 +286,9 @@ OO_backup(n)
 }
 
 OO_dodefault(numout, numcopy)
-	int numout, numcopy;
+	register int numout, numcopy;
 {
-	register struct instr **p,**q;
+	register p_instr *p, *q;
 	q = (p = OO_patternqueue) + numout;
 	while(numcopy--) {
 		if(numout) {
@@ -360,60 +306,75 @@ PRIVATE
 printstate(mess)
 	char *mess;
 {
-	struct instr **p;
-	fprint(STDERR,"%s - state: ",mess);
+	p_instr	*p;
+	fprintf(stderr,"%s - state: ",mess);
 	p = outputqueue;
 	while(p<nextoutput)
 		prtinst(*p++);
-	fprint(STDERR," |==| ");
+	fprintf(stderr," |==| ");
 	p = OO_patternqueue;
 	while(p<OO_nxtpatt)
 		prtinst(*p++);
-	fprint(STDERR," |==| ");
+	fprintf(stderr," |==| ");
 	p = OO_bkupqueue;
 	while(p<OO_nxtbackup)
 		prtinst(*p++);
-	fprint(STDERR,"\n");
+	fprintf(stderr,"\n");
 }
 
 PRIVATE
 prtinst(p)
-	struct instr *p;
+	p_instr	p;
 {
-	switch(p->opcode) {
-	default:
-		fprint(STDERR,"%s",em_mnem[p->opcode-sp_fmnem]);
+	switch(p->em_type) {
+	case EM_MNEM:
+		if(p->em_opcode == OTHER)
+			fprintf(stderr,"OTHER");
+		else
+			fprintf(stderr,"%s",em_mnem[p->em_opcode-sp_fmnem]);
 		break;
-	case OTHER:
-		fprint(STDERR,"OTHER");
+	case EM_PSEU:
+	case EM_STARTMES:
+		fprintf(stderr,"%s",em_pseu[p->em_opcode-sp_fpseu]);
 		break;
-	case op_lab:
+	case EM_MESARG:
+	case EM_ENDMES:
+		break;
+	case EM_DEFILB:
+		fprintf(stderr,"%ld", (long)p->em_ilb);
+		break;
+	case EM_DEFDLB:
+		fprintf(stderr,"%ld", (long)p->em_dlb);
+		break;
+	case EM_DEFDNAM:
+		fprintf(stderr,"%d", p->em_dnam);
+		break;
+	case EM_ERROR:
+	case EM_FATAL:
+	case EM_EOF:
 		break;
 	}
-	switch(p->argtype) {
-	case none_ptyp:
-		fprint(STDERR," ");
+	switch(p->em_argtype) {
+	case 0:
+		fprintf(stderr," ");
 		break;
 	case cst_ptyp:
-		fprint(STDERR," %d ",p->acst);
-		break;
-	case lab_ptyp:
-		fprint(STDERR,"%d: ",p->alab);
+		fprintf(stderr," %d ",p->em_cst);
 		break;
 	case nof_ptyp:
-		fprint(STDERR," .%d+%d ",p->adlb,p->asoff);
+		fprintf(stderr," .%d+%d ",p->em_dlb,p->em_off);
 		break;
 	case sof_ptyp:
-		fprint(STDERR," %s+%d ",p->adnam,p->asoff);
+		fprintf(stderr," %s+%d ",p->em_dnam,p->em_off);
 		break;
 	case ilb_ptyp:
-		fprint(STDERR," *%d ",p->alab);
+		fprintf(stderr," *%d ",p->em_ilb);
 		break;
 	case pro_ptyp:
-		fprint(STDERR," $%s ",p->apnam);
+		fprintf(stderr," $%s ",p->em_pnam);
 		break;
 	default:
-		fatal(" prtinst - Unregognized arg %d ",p->argtype);
+		fatal(" prtinst - Unregognized arg %d ",p->em_argtype);
 	}
 }
 #endif
diff --git a/modules/src/em_opt/nopt.h b/modules/src/em_opt/nopt.h
index a7c2b7dc4..ead6201b1 100644
--- a/modules/src/em_opt/nopt.h
+++ b/modules/src/em_opt/nopt.h
@@ -1,4 +1,5 @@
 /* $Header$ */
+#include <stdio.h>
 #include <em_spec.h>
 #include <em_mnem.h>
 #include <em_pseu.h>
@@ -10,60 +11,40 @@
 #include <em_comp.h>
 #include <system.h>
 #include <idf_pkg.spec>
-#include <emO_code.h>
+#include "emO_code.h"
 
-#define NULL 0
-#define FLUSHDFA()	if(OO_state) { OO_inop(OTHER); OO_dfa(OTHER); } \
-			else if(OO_noutput) OO_flush();
-#define NEXTEM()	((OO_nxtbackup>OO_bkupqueue)?\
-				((*OO_nxtpatt++ = *(--OO_nxtbackup))->opcode):\
-				0)
+#define OTHER 255
 
-#define op_lab 255
-#define OTHER  254
-#define none_ptyp 0
+#define FLUSHDFA()	if(OO_state) {\
+				*OO_nxtpatt++ = OO_OTHER; OO_dfa(OTHER);\
+			} else if(OO_noutput) OO_flush();
 
+#define GETINSTR() (OO_nxtifree>OO_freeiqueue)?*(--OO_nxtifree):\
+	((p_instr)Malloc(sizeof(struct e_instr)))
 
-struct e_instr *EM_getinstr();
+#define op_lab sp_ilb1
 
-struct instr {
-	int opcode;
-	int argtype;
-	union {
-		arith cst;
-		label lab;
-		char  *pnam;
-		struct {
-			label dlb;
-			arith noff;
-		} ndlb;
-		struct {
-			char  *dnam;
-			arith soff;
-		} sdlb;
-	} val;
-#define acst val.cst
-#define alab val.lab
-#define apnam val.pnam
-#define adlb val.ndlb.dlb
-#define anoff val.ndlb.noff
-#define adnam val.sdlb.dnam
-#define asoff val.sdlb.soff
-};
+typedef struct e_instr *p_instr;
 
-extern struct instr **OO_patternqueue;
-extern struct instr **OO_nxtpatt;
-extern struct instr **OO_bkupqueue;
-extern struct instr **OO_nxtbackup;
-extern int OO_state;
-extern int OO_noutput;	/* number of instructions in output queue */
-extern int OO_WSIZE;	/* wordlength */
-extern int OO_PSIZE;	/* pointer length */
+extern p_instr	*OO_freeiqueue;
+extern p_instr	*OO_nxtifree;
+extern p_instr	*OO_patternqueue;
+extern p_instr	*OO_nxtpatt;
+extern p_instr	*OO_bkupqueue;
+extern p_instr	*OO_nxtbackup;
+extern p_instr	OO_OTHER;
+extern int	OO_state;
+extern int	OO_noutput;	/* number of instructions in output queue */
+extern int	OO_WSIZE;	/* wordlength */
+extern int	OO_PSIZE;	/* pointer length */
 #ifdef STATS
-extern int OO_wrstats;			/* statistics output */
+extern int	OO_wrstats;			/* statistics output */
 #endif
 
-#define CST(p)		(p->acst)
-#define PNAM(p)		(p->apnam)
-#define LAB(p)		(p->alab)
-#define DEFILB(p)	(p->alab)
+extern char	*OO_freestr();
+
+#define CST(p)		(p->em_cst)
+#define PNAM(p)		(p->em_pnam)
+#define LAB(p)		(p->em_ilb)
+#define DEFILB(p)	(p->em_ilb)
+
diff --git a/modules/src/em_opt/outcalls.c b/modules/src/em_opt/outcalls.c
index 30830dde2..3e4bb13ed 100644
--- a/modules/src/em_opt/outcalls.c
+++ b/modules/src/em_opt/outcalls.c
@@ -1,5 +1,5 @@
 #ifndef NORCSID
-static char rcsid[] = "$Header$";
+static char rcsidp4[] = "$Header$";
 #endif
 
 #include "parser.h"
@@ -9,8 +9,8 @@ outputincalls()
 	struct idf *op;
 	int opcode;
 	char *s;
-	if(!sys_open("incalls.r",OP_WRITE,&ofile)) {
-		fprint(STDERR,"Fatal Error: cannot open output file incalls.r\n");
+	if((ofile=fopen("incalls.r","w"))==NULL) {
+		fprintf(stderr,"Fatal Error: cannot open output file incalls.r\n");
 		sys_stop(S_EXIT);
 	}
 	for(op=ops;op!=(struct idf *)NULL;op=op->id_nextidf) {
@@ -18,98 +18,98 @@ outputincalls()
 		s = op->id_text;
 		switch(op->id_argfmt) {
 		case NOARG:
-			fprint(ofile,"%s\t|\t|\n",s);
+			fprintf(ofile,"%s\t|\t|\n",s);
 			if(op->id_used) {
-				fprint(ofile,"\tOO_inop(op_%s);\n",s);
-				fprint(ofile,"\tOO_dfa(op_%s);\n",s);
+				fprintf(ofile,"\tOO_inop(op_%s);\n",s);
+				fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
 			}
 			else {
-				fprint(ofile,"\tFLUSHDFA();\n");
-				fprint(ofile,"\tO_%s();\n",s);
+				fprintf(ofile,"\tFLUSHDFA();\n");
+				fprintf(ofile,"\tC_%s();\n",s);
 			}
 			break;
 		case CSTOPT:
-			fprint(ofile,"%s_narg\t|\t|\n",s);
+			fprintf(ofile,"%s_narg\t|\t|\n",s);
 			if(op->id_used) {
-				fprint(ofile,"\tOO_inop(op_%s);\n",s);
-				fprint(ofile,"\tOO_dfa(op_%s);\n",s);
+				fprintf(ofile,"\tOO_inop(op_%s);\n",s);
+				fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
 			}
 			else {
-				fprint(ofile,"\tFLUSHDFA();\n");
-				fprint(ofile,"\tO_%s_narg();\n",s);
+				fprintf(ofile,"\tFLUSHDFA();\n");
+				fprintf(ofile,"\tC_%s_narg();\n",s);
 			}
 			/* fall thru */
 		case CST:
-			fprint(ofile,"%s\t| int:n\t|\n",s);
+			fprintf(ofile,"%s\t| int:n\t|\n",s);
 			if(op->id_used) {
-				fprint(ofile,"\tOO_incst(op_%s,n);\n",s);
-				fprint(ofile,"\tOO_dfa(op_%s);\n",s);
+				fprintf(ofile,"\tOO_incst(op_%s,n);\n",s);
+				fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
 			}
 			else {
-				fprint(ofile,"\tFLUSHDFA();\n");
-				fprint(ofile,"\tO_%s(n);\n",s);
+				fprintf(ofile,"\tFLUSHDFA();\n");
+				fprintf(ofile,"\tC_%s(n);\n",s);
 			}
 			break;
 		case DEFILB:
-			fprint(ofile,"df_ilb\t| label:l\t|\n");
+			fprintf(ofile,"df_ilb\t| label:l\t|\n");
 			if(op->id_used) {
-				fprint(ofile,"\tOO_indefilb(op_%s,l);\n",s);
-				fprint(ofile,"\tOO_dfa(op_%s);\n",s);
+				fprintf(ofile,"\tOO_indefilb(op_%s,l);\n",s);
+				fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
 			}
 			else {
-				fprint(ofile,"\tFLUSHDFA();\n");
-				fprint(ofile,"\tO_df_ilb(l);\n",s);
+				fprintf(ofile,"\tFLUSHDFA();\n");
+				fprintf(ofile,"\tC_df_ilb(l);\n",s);
 			}
 			break;
 		case PNAM:
-			fprint(ofile,"%s\t| char *:s\t|\n",s);
+			fprintf(ofile,"%s\t| char *:s\t|\n",s);
 			if(op->id_used) {
-				fprint(ofile,"\tOO_inpnam(op_%s,s);\n",s);
-				fprint(ofile,"\tOO_dfa(op_%s);\n",s);
+				fprintf(ofile,"\tOO_inpnam(op_%s,s);\n",s);
+				fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
 			}
 			else {
-				fprint(ofile,"\tFLUSHDFA();\n");
-				fprint(ofile,"\tO_%s(s);\n",s);
+				fprintf(ofile,"\tFLUSHDFA();\n");
+				fprintf(ofile,"\tC_%s(s);\n",s);
 			}
 			break;
 		case LAB:
-			fprint(ofile,"%s\t| label:l\t|\n",s);
+			fprintf(ofile,"%s\t| label:l\t|\n",s);
 			if(op->id_used) {
-				fprint(ofile,"\tOO_inlab(op_%s,l);\n",s);
-				fprint(ofile,"\tOO_dfa(op_%s);\n",s);
+				fprintf(ofile,"\tOO_inlab(op_%s,l);\n",s);
+				fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
 			}
 			else {
-				fprint(ofile,"\tFLUSHDFA();\n");
-				fprint(ofile,"\tO_%s(l);\n",s);
+				fprintf(ofile,"\tFLUSHDFA();\n");
+				fprintf(ofile,"\tC_%s(l);\n",s);
 			}
 			break;
 		case EXT:
-			fprint(ofile,"%s\t| int:n\t|\n",s);
+			fprintf(ofile,"%s\t| int:n\t|\n",s);
 			if(op->id_used) {
-				fprint(ofile,"\tOO_incst(op_%s,n);\n",s);
-				fprint(ofile,"\tOO_dfa(op_%s);\n",s);
+				fprintf(ofile,"\tOO_incst(op_%s,n);\n",s);
+				fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
 			}
 			else {
-				fprint(ofile,"\tFLUSHDFA();\n");
-				fprint(ofile,"\tO_%s(n);\n",s);
+				fprintf(ofile,"\tFLUSHDFA();\n");
+				fprintf(ofile,"\tC_%s(n);\n",s);
 			}
-			fprint(ofile,"%s_dnam\t| char *:s int:n\t|\n",s);
+			fprintf(ofile,"%s_dnam\t| char *:s int:n\t|\n",s);
 			if(op->id_used) {
-				fprint(ofile,"\tOO_indnam(op_%s,s,n);\n",s);
-				fprint(ofile,"\tOO_dfa(op_%s);\n",s);
+				fprintf(ofile,"\tOO_indnam(op_%s,s,n);\n",s);
+				fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
 			}
 			else {
-				fprint(ofile,"\tFLUSHDFA();\n");
-				fprint(ofile,"\tO_%s_dnam(s,n);\n",s);
+				fprintf(ofile,"\tFLUSHDFA();\n");
+				fprintf(ofile,"\tC_%s_dnam(s,n);\n",s);
 			}
-			fprint(ofile,"%s_dlb\t| label:l int:n\t|\n",s);
+			fprintf(ofile,"%s_dlb\t| label:l int:n\t|\n",s);
 			if(op->id_used) {
-				fprint(ofile,"\tOO_indlb(op_%s,l,n);\n",s);
-				fprint(ofile,"\tOO_dfa(op_%s);\n",s);
+				fprintf(ofile,"\tOO_indlb(op_%s,l,n);\n",s);
+				fprintf(ofile,"\tOO_dfa(op_%s);\n",s);
 			}
 			else {
-				fprint(ofile,"\tFLUSHDFA();\n");
-				fprint(ofile,"\tO_%s_dlb(l,n);\n",s);
+				fprintf(ofile,"\tFLUSHDFA();\n");
+				fprintf(ofile,"\tC_%s_dlb(l,n);\n",s);
 			}
 			break;
 		}
diff --git a/modules/src/em_opt/outputdfa.c b/modules/src/em_opt/outputdfa.c
index b5efa62d1..8db5b4ea7 100644
--- a/modules/src/em_opt/outputdfa.c
+++ b/modules/src/em_opt/outputdfa.c
@@ -1,16 +1,16 @@
 #ifndef NORCSID
-static char rcsid[] = "$Header$";
+static char rcsidp5[] = "$Header$";
 #endif
 
 #include "parser.h"
 #include "Lpars.h"
 
-File *ofile;
+FILE *ofile;
 
 outputnopt()
 {
-	if(!sys_open("dfa.c",OP_WRITE,&ofile)) {
-		fprint(STDERR,"Couldn't open dfa.c for output\n");
+	if((ofile=fopen("dfa.c","w"))==NULL) {
+		fprintf(stderr,"Couldn't open dfa.c for output\n");
 		sys_stop(S_EXIT);
 	}
 	outheaders();
@@ -24,28 +24,28 @@ outputnopt()
 PRIVATE
 outheaders()
 {
-	fprint(ofile,"#include \"nopt.h\"\n");
-	fprint(ofile,"\n");
-	fprint(ofile,"int maxpattern = %d;\n", longestpattern);
-	fprint(ofile,"\n");
+	fprintf(ofile,"#include \"nopt.h\"\n");
+	fprintf(ofile,"\n");
+	fprintf(ofile,"int OO_maxpattern = %d;\n", longestpattern);
+	fprintf(ofile,"\n");
 }
 
 PRIVATE
 outtables()
 {
 	int s;
-	fprint(ofile,"static struct defact {\n");
-	fprint(ofile,"\tint numoutput;\n");
-	fprint(ofile,"\tint numcopy;\n");
-	fprint(ofile,"\tint nextstate;\n");
-	fprint(ofile,"} defaultactions[] = {\n");
+	fprintf(ofile,"static struct defact {\n");
+	fprintf(ofile,"\tint numoutput;\n");
+	fprintf(ofile,"\tint numcopy;\n");
+	fprintf(ofile,"\tint nextstate;\n");
+	fprintf(ofile,"} defaultactions[] = {\n");
 	for(s=0;s<=higheststate;s++) {
 		findfail(s);
 		if(s%4==3)
-			fprint(ofile,"\n");
+			fprintf(ofile,"\n");
 	}
-	fprint(ofile,"};\n");
-	fprint(ofile,"\n");
+	fprintf(ofile,"};\n");
+	fprintf(ofile,"\n");
 }
 
 PRIVATE
@@ -54,54 +54,56 @@ outdfa()
 	int s;
 	struct idf *op;
 	struct state *p;
-	fprint(ofile,"int OO_state = 0;\n");
-	fprint(ofile,"\n");
-	fprint(ofile,"OO_dfa(last) int last; {\n");
-	fprint(ofile,"\twhile(last) {\n");
-	fprint(ofile,"\t\tswitch(last) {\n");
+	fprintf(ofile,"int OO_state = 0;\n");
+	fprintf(ofile,"\n");
+	fprintf(ofile,"OO_dfa(last) register int last; {\n");
+	fprintf(ofile,"\tfor(;;) {\n");
+	fprintf(ofile,"\t\tswitch(last) {\n");
 	for(op=ops;op!=(struct idf *)NULL;op=op->id_nextidf) {
 		if(!op->id_used)
 			continue;
-		fprint(ofile,"\t\tcase op_%s:\n",op->id_text);
-		fprint(ofile,"\t\t\tswitch(OO_state) {\n");
+		fprintf(ofile,"\t\tcase op_%s:\n",op->id_text);
+		fprintf(ofile,"\t\t\tswitch(OO_state) {\n");
 		if(!op->id_startpatt) {
-				fprint(ofile,"\t\t\tcase 0: ");
-				fprint(ofile,"OO_out(*--OO_nxtpatt); ");
-				fprint(ofile,"break;\n");
+				fprintf(ofile,"\t\t\tcase 0: ");
+				fprintf(ofile,"OO_out(*--OO_nxtpatt); ");
+				fprintf(ofile,"break;\n");
 		}
 		for(s=0;s<=higheststate;s++)
 			for(p=states[s];p!=(struct state *)NULL;p=p->next) {
 				if(p->op==op) {
-					fprint(ofile,"\t\t\tcase %d: ",s);
+					fprintf(ofile,"\t\t\tcase %d: ",s);
 					if(actions[p->goto_state]==(struct action *)NULL)
-						fprint(ofile,"OO_state = %d; ",p->goto_state);
-					else fprint(ofile,"OO_dotrans(%d); ",p->goto_state);
-					fprint(ofile,"break;\n");
+						fprintf(ofile,"OO_state = %d; ",p->goto_state);
+					else fprintf(ofile,"OO_dotrans(%d); ",p->goto_state);
+					fprintf(ofile,"break;\n");
 				}
 			}
-		fprint(ofile,"\t\t\tdefault: dodefaultaction(); break;\n");
-		fprint(ofile,"\t\t\t}\n");
-		fprint(ofile,"\t\t\tbreak;\n");
+		fprintf(ofile,"\t\t\tdefault: dodefaultaction(); break;\n");
+		fprintf(ofile,"\t\t\t}\n");
+		fprintf(ofile,"\t\t\tbreak;\n");
 	}
-	fprint(ofile,"\t\tdefault:\n");
-	fprint(ofile,"\t\t\tif(OO_state) dodefaultaction();\n");
-	fprint(ofile,"\t\t\telse {\n");
-	fprint(ofile,"\t\t\t\tOO_flush();\n");
-	fprint(ofile,"\t\t\t\tOO_mkcalls(*--OO_nxtpatt);\n");
-	fprint(ofile,"\t\t\t\tOO_free(*OO_nxtpatt);\n");
-	fprint(ofile,"\t\t\t}\n");
-	fprint(ofile,"\t\t\tbreak;\n");
-	fprint(ofile,"\t\tcase OTHER:\n");
-	fprint(ofile,"\t\t\tif(OO_state) dodefaultaction();\n");
-	fprint(ofile,"\t\t\telse {\n");
-	fprint(ofile,"\t\t\t\tOO_flush();\n");
-	fprint(ofile,"\t\t\t\tOO_free(*--OO_nxtpatt);\n");
-	fprint(ofile,"\t\t\t}\n");
-	fprint(ofile,"\t\t\tbreak;\n");
-	fprint(ofile,"\t\t}\n");
-	fprint(ofile,"\tlast = NEXTEM();\n");
-	fprint(ofile,"\t}\n");
-	fprint(ofile,"}\n");
+	fprintf(ofile,"\t\tdefault:\n");
+	fprintf(ofile,"\t\t\tif(OO_state) dodefaultaction();\n");
+	fprintf(ofile,"\t\t\telse {\n");
+	fprintf(ofile,"\t\t\t\tOO_flush();\n");
+	fprintf(ofile,"\t\t\t\tEM_mkcalls(*--OO_nxtpatt);\n");
+	fprintf(ofile,"\t\t\t\tOO_free(*OO_nxtpatt);\n");
+	fprintf(ofile,"\t\t\t}\n");
+	fprintf(ofile,"\t\t\tbreak;\n");
+	fprintf(ofile,"\t\tcase OTHER:\n");
+	fprintf(ofile,"\t\t\tif(OO_state) dodefaultaction();\n");
+	fprintf(ofile,"\t\t\telse {\n");
+	fprintf(ofile,"\t\t\t\tOO_flush();\n");
+	fprintf(ofile,"\t\t\t\t--OO_nxtpatt;\n");
+	fprintf(ofile,"\t\t\t}\n");
+	fprintf(ofile,"\t\t\tbreak;\n");
+	fprintf(ofile,"\t\t}\n");
+	fprintf(ofile,"\t\tif (OO_nxtbackup==OO_bkupqueue)\n");
+	fprintf(ofile,"\t\t\treturn;\n");
+	fprintf(ofile,"\t\tlast = ((*OO_nxtpatt++ = *(--OO_nxtbackup))->em_opcode);\n");
+	fprintf(ofile,"\t}\n");
+	fprintf(ofile,"}\n");
 }
 
 PRIVATE
@@ -110,7 +112,7 @@ outmnems(l)
 {
 	int i;
 	for(i=1;i<=l.m_len;i++) 
-		fprint(ofile,"%s ",l.m_elems[i-1]->op_code->id_text);
+		fprintf(ofile,"%s ",l.m_elems[i-1]->op_code->id_text);
 }
 
 PRIVATE
@@ -121,61 +123,61 @@ outdotrans()
 	struct state *p;
 	struct action *a;
 	int seennontested;
-	if(!sys_open("trans.c",OP_WRITE,&ofile)) {
-		fprint(STDERR,"Fatal Error: cannot open output file trans.c\n");
+	if((ofile=fopen("trans.c","w"))==NULL) {
+		fprintf(stderr,"Fatal Error: cannot open output file trans.c\n");
 		sys_stop(S_EXIT);
 	}
-	fprint(ofile,"#include \"nopt.h\"\n\n");
-	fprint(ofile,"\nOO_dotrans(s) int s; {\n");
-	fprint(ofile,"\tregister struct instr **patt = OO_patternqueue;\n");
-	fprint(ofile,"\tswitch(OO_state=s) {\n");
-	fprint(ofile,"\tdefault: return;\n");
+	fprintf(ofile,"#include \"nopt.h\"\n\n");
+	fprintf(ofile,"\nOO_dotrans(s) int s; {\n");
+	fprintf(ofile,"\tregister p_instr *patt = OO_patternqueue;\n");
+	fprintf(ofile,"\tswitch(OO_state=s) {\n");
+	fprintf(ofile,"\tdefault: return;\n");
 	for(s=0;s<=higheststate;s++)
 		if(actions[s]!=(struct action *)NULL) {
-			fprint(ofile,"\tcase %d: /*",s);
+			fprintf(ofile,"\tcase %d: /*",s);
 			outmnems(patterns[s]);
-			fprint(ofile," */\n");
+			fprintf(ofile," */\n");
 			seennontested=0;
 			for(a=actions[s];a!=(struct action *)NULL;a=a->next) {
 				if(a->test!=(struct exp_node *)NULL) {
-					fprint(ofile,"\t\tif(");
+					fprintf(ofile,"\t\tif(");
 					outexp(a->test,s);
-					fprint(ofile,") {\n");
+					fprintf(ofile,") {\n");
 					outoneaction(s,a);
-					fprint(ofile,"\t\t\tgoto free%d;\n",patterns[s].m_len);
-					fprint(ofile,"\t\t}\n");
+					fprintf(ofile,"\t\t\tgoto free%d;\n",patterns[s].m_len);
+					fprintf(ofile,"\t\t}\n");
 				}
 				else {
 					if(seennontested) {
-						fprint(STDERR,"parser: more than one untested action on state %d\n",s);
+						fprintf(stderr,"parser: more than one untested action on state %d\n",s);
 						nerrors++;
 					}
 					seennontested++;
 					outoneaction(s,a);
-					fprint(ofile,"\t\t\tgoto free%d;\n",patterns[s].m_len);
+					fprintf(ofile,"\t\t\tgoto free%d;\n",patterns[s].m_len);
 				}
 			}
 			if(!seennontested)
-				fprint(ofile,"\t\treturn;\n");
+				fprintf(ofile,"\t\treturn;\n");
 		}
-	fprint(ofile,"\t}\n");
+	fprintf(ofile,"\t}\n");
 	for(i=longestpattern;i>0;i--)
-		fprint(ofile," free%d: OO_free(*--OO_nxtpatt);\n",i);
-	fprint(ofile," free0: ;\n");
-	fprint(ofile,"\tOO_state=0;\n");
-	fprint(ofile,"}\n");
-	fprint(ofile,"\n");
+		fprintf(ofile," free%d: OO_free(*--OO_nxtpatt);\n",i);
+	fprintf(ofile," free0: ;\n");
+	fprintf(ofile,"\tOO_state=0;\n");
+	fprintf(ofile,"}\n");
+	fprintf(ofile,"\n");
 }
 
 PRIVATE
 outdodefault()
 {
-	fprint(ofile,"\nstatic dodefaultaction() {\n");
-	fprint(ofile,"\tregister struct defact *p = &defaultactions[OO_state];\n");
-	fprint(ofile,"\tOO_pushback(*--OO_nxtpatt);\n");
-	fprint(ofile,"\tOO_dodefault(p->numoutput,p->numcopy);\n");
-	fprint(ofile,"\tOO_dotrans(p->nextstate);\n");
-	fprint(ofile,"}\n");
+	fprintf(ofile,"\nstatic dodefaultaction() {\n");
+	fprintf(ofile,"\tregister struct defact *p = &defaultactions[OO_state];\n");
+	fprintf(ofile,"\tOO_pushback(*--OO_nxtpatt);\n");
+	fprintf(ofile,"\tOO_dodefault(p->numoutput,p->numcopy);\n");
+	fprintf(ofile,"\tOO_dotrans(p->nextstate);\n");
+	fprintf(ofile,"}\n");
 }
 
 PRIVATE
@@ -183,13 +185,13 @@ outoneaction(s,a)
 	int s;
 	struct action *a;
 {
-	fprint(ofile,"\t\t/* ");
-	fprint(ofile," -> ");
+	fprintf(ofile,"\t\t/* ");
+	fprintf(ofile," -> ");
 	outmnems(a->replacement);
-	fprint(ofile," */\n");
-	fprint(ofile,"#ifdef STATS\n");
-	fprint(ofile,"\t\t\tif(OO_wrstats) fprint(STDERR,\"%d\\n\");\n",a->linenum);
-	fprint(ofile,"#endif\n");
+	fprintf(ofile," */\n");
+	fprintf(ofile,"#ifdef STATS\n");
+	fprintf(ofile,"\t\t\tif(OO_wrstats) fprintf(stderr,\"%d\\n\");\n",a->linenum);
+	fprintf(ofile,"#endif\n");
 	outrepl(s,patterns[s],a->replacement);
 	findworst(a->replacement);
 }
@@ -210,33 +212,33 @@ outrepl(state,patt,repl)
 		char *mnem = ri->op_code->id_text;
 		switch(ri->op_code->id_argfmt) {
 		case NOARG:
-			fprint(ofile,"\t\t\tOO_outop(op_%s);\n",mnem);
+			fprintf(ofile,"\t\t\tOO_outop(op_%s);\n",mnem);
 			break;
 		case CST:
 		case CSTOPT:
-			fprint(ofile,"\t\t\tOO_outcst(op_%s,",mnem);
+			fprintf(ofile,"\t\t\tOO_outcst(op_%s,",mnem);
 			outexp(ri->arg,state);
-			fprint(ofile,");\n");
+			fprintf(ofile,");\n");
 			break;
 		case LAB:
-			fprint(ofile,"\t\t\tOO_outlab(op_%s,",mnem);
+			fprintf(ofile,"\t\t\tOO_outlab(op_%s,",mnem);
 			outexp(ri->arg,state);
-			fprint(ofile,");\n");
+			fprintf(ofile,");\n");
 			break;
 		case DEFILB:
-			fprint(ofile,"\t\t\tOO_outdefilb(op_%s,",mnem);
+			fprintf(ofile,"\t\t\tOO_outdefilb(op_%s,",mnem);
 			outexp(ri->arg,state);
-			fprint(ofile,");\n");
+			fprintf(ofile,");\n");
 			break;
 		case PNAM:
-			fprint(ofile,"\t\t\tOO_outpnam(op_%s,",mnem);
+			fprintf(ofile,"\t\t\tOO_outpnam(op_%s,",mnem);
 			outexp(ri->arg,state);
-			fprint(ofile,");\n");
+			fprintf(ofile,");\n");
 			break;
 		case EXT:
-			fprint(ofile,"\t\t\tOO_outext(op_%s,",mnem);
+			fprintf(ofile,"\t\t\tOO_outext(op_%s,",mnem);
 			outexp(ri->arg,state);
-			fprint(ofile,");\n");
+			fprintf(ofile,");\n");
 			break;
 		}
 	}
@@ -266,30 +268,30 @@ outexp(e,state)
 	case GE:
 	case LSHIFT:
 	case RSHIFT:
-		fprint(ofile,"(");
+		fprintf(ofile,"(");
 		outexp(e->exp_left,state);
 		outop(e->node_type);
 		outexp(e->exp_right,state);
-		fprint(ofile,")");
+		fprintf(ofile,")");
 		break;
 	case NOT:
 	case COMP:
 	case UPLUS:
 	case UMINUS:
-		fprint(ofile,"(");
+		fprintf(ofile,"(");
 		outop(e->node_type);
 		outexp(e->exp_left,state);
-		fprint(ofile,")");
+		fprintf(ofile,")");
 		break;
 	case DEFINED:
-		fprint(ofile,"(patt[%d]->argtype!=none_ptyp)",e->leaf_val-1);
+		fprintf(ofile,"(patt[%d]->em_argtype)",e->leaf_val-1);
 		break;
 	case UNDEFINED:
-		fprint(ofile,"(patt[%d]->argtype==none_ptyp)",e->leaf_val-1);
+		fprintf(ofile,"(patt[%d]->em_argtype==0)",e->leaf_val-1);
 		break;
 	case COMMA:
 		outext(e->exp_left);
-		fprint(ofile,","); outexp(e->exp_right,state);
+		fprintf(ofile,","); outexp(e->exp_right,state);
 		break;
 	case SAMESIGN:
 	case SFIT:
@@ -297,48 +299,48 @@ outexp(e,state)
 	case ROTATE:
 		outop(e->node_type);
 		outexp(e->exp_left,state);
-		fprint(ofile,",");
+		fprintf(ofile,",");
 		outexp(e->exp_right,state);
-		fprint(ofile,")");
+		fprintf(ofile,")");
 		break;
 	case SAMEEXT:
 	case SAMENAM:
 		outop(e->node_type);
 		outext(e->exp_left);
-		fprint(ofile,",");
+		fprintf(ofile,",");
 		outext(e->exp_right,state);
-		fprint(ofile,")");
+		fprintf(ofile,")");
 		break;
 	case PATARG:
 		switch(patterns[state].m_elems[e->leaf_val-1]->op_code->id_argfmt) {
 		case NOARG:
-			fprint(STDERR,"error: mnem %d has no argument\n",e->leaf_val);
+			fprintf(stderr,"error: mnem %d has no argument\n",e->leaf_val);
 			nerrors++;
 			break;
 		case CST:
 		case CSTOPT:
-			fprint(ofile,"CST(patt[%d])",e->leaf_val-1);
+			fprintf(ofile,"CST(patt[%d])",e->leaf_val-1);
 			break;
 		case LAB:
-			fprint(ofile,"LAB(patt[%d])",e->leaf_val-1);
+			fprintf(ofile,"LAB(patt[%d])",e->leaf_val-1);
 			break;
 		case DEFILB:
-			fprint(ofile,"DEFILB(patt[%d])",e->leaf_val-1);
+			fprintf(ofile,"DEFILB(patt[%d])",e->leaf_val-1);
 			break;
 		case PNAM:
-			fprint(ofile,"PNAM(patt[%d])",e->leaf_val-1);
+			fprintf(ofile,"PNAM(patt[%d])",e->leaf_val-1);
 			break;
 		case EXT:
-			fprint(ofile,"OO_offset(patt[%d])",e->leaf_val-1);
+			fprintf(ofile,"OO_offset(patt[%d])",e->leaf_val-1);
 			break;
 		}
 		break;
 	case PSIZE:
-		fprint(ofile,"OO_PSIZE"); break;
+		fprintf(ofile,"OO_PSIZE"); break;
 	case WSIZE:
-		fprint(ofile,"OO_WSIZE"); break;
+		fprintf(ofile,"OO_WSIZE"); break;
 	case INT:
-		fprint(ofile,"%d",e->leaf_val); break;
+		fprintf(ofile,"%d",e->leaf_val); break;
 	}
 }
 
@@ -347,10 +349,10 @@ outext(e)
 	struct exp_node *e;
 {
 	if(e->node_type!=PATARG) {
-		fprint(STDERR,"Internal error in outext of parser\n");
+		fprintf(stderr,"Internal error in outext of parser\n");
 		nerrors++;
 	}
-	fprint(ofile,"patt[%d]",e->leaf_val-1);
+	fprintf(ofile,"patt[%d]",e->leaf_val-1);
 }
 
 PRIVATE
@@ -358,33 +360,33 @@ outop(op)
 	int op;
 {
 	switch(op) {
-	case LOGAND:	fprint(ofile,"&&");	break;
-	case LOGOR:	fprint(ofile,"||");	break;
-	case BITAND:	fprint(ofile,"&");	break;
-	case BITOR:	fprint(ofile,"|");	break;
-	case XOR:	fprint(ofile,"^");	break;
-	case MINUS:	fprint(ofile,"-");	break;
-	case PLUS:	fprint(ofile,"+");	break;
-	case TIMES:	fprint(ofile,"*");	break;
-	case DIV:	fprint(ofile,"/");	break;
-	case MOD:	fprint(ofile,"%%");	break;
-	case EQ:	fprint(ofile,"==");	break;
-	case NE:	fprint(ofile,"!=");	break;
-	case LT:	fprint(ofile,"<");	break;
-	case LE:	fprint(ofile,"<=");	break;
-	case GT:	fprint(ofile,">");	break;
-	case GE:	fprint(ofile,">=");	break;
-	case LSHIFT:	fprint(ofile,"<<");	break;
-	case RSHIFT:	fprint(ofile,">>");	break;
-	case NOT:	fprint(ofile,"!");	break;
-	case COMP:	fprint(ofile,"~");	break;
-	case UPLUS:	fprint(ofile,"+");	break;
-	case UMINUS:	fprint(ofile,"-");	break;
-	case SAMESIGN:	fprint(ofile,"OO_signsame(");	break;
-	case SFIT:	fprint(ofile,"OO_sfit(");	break;
-	case UFIT:	fprint(ofile,"OO_ufit(");	break;
-	case ROTATE:	fprint(ofile,"OO_rotate(");	break;
-	case SAMEEXT:	fprint(ofile,"OO_extsame(");	break;
-	case SAMENAM:	fprint(ofile,"OO_namsame(");	break;
+	case LOGAND:	fprintf(ofile,"&&");	break;
+	case LOGOR:	fprintf(ofile,"||");	break;
+	case BITAND:	fprintf(ofile,"&");	break;
+	case BITOR:	fprintf(ofile,"|");	break;
+	case XOR:	fprintf(ofile,"^");	break;
+	case MINUS:	fprintf(ofile,"-");	break;
+	case PLUS:	fprintf(ofile,"+");	break;
+	case TIMES:	fprintf(ofile,"*");	break;
+	case DIV:	fprintf(ofile,"/");	break;
+	case MOD:	fprintf(ofile,"%%");	break;
+	case EQ:	fprintf(ofile,"==");	break;
+	case NE:	fprintf(ofile,"!=");	break;
+	case LT:	fprintf(ofile,"<");	break;
+	case LE:	fprintf(ofile,"<=");	break;
+	case GT:	fprintf(ofile,">");	break;
+	case GE:	fprintf(ofile,">=");	break;
+	case LSHIFT:	fprintf(ofile,"<<");	break;
+	case RSHIFT:	fprintf(ofile,">>");	break;
+	case NOT:	fprintf(ofile,"!");	break;
+	case COMP:	fprintf(ofile,"~");	break;
+	case UPLUS:	fprintf(ofile,"+");	break;
+	case UMINUS:	fprintf(ofile,"-");	break;
+	case SAMESIGN:	fprintf(ofile,"OO_signsame(");	break;
+	case SFIT:	fprintf(ofile,"OO_sfit(");	break;
+	case UFIT:	fprintf(ofile,"OO_ufit(");	break;
+	case ROTATE:	fprintf(ofile,"OO_rotate(");	break;
+	case SAMEEXT:	fprintf(ofile,"OO_extsame(");	break;
+	case SAMENAM:	fprintf(ofile,"OO_namsame(");	break;
 	}
 }
diff --git a/modules/src/em_opt/parser.g b/modules/src/em_opt/parser.g
index 8573236ca..525683df1 100644
--- a/modules/src/em_opt/parser.g
+++ b/modules/src/em_opt/parser.g
@@ -1,4 +1,3 @@
-/* $Header$ */
 /* Parser to read optimization patterns of the form:
 		op1 op2 ... test : action
 	or
@@ -13,6 +12,10 @@
 %start	parser, input;
 
 {
+#ifndef NORCSID
+static char rcsidp1[] = "$Header$";
+#endif
+
 #include "parser.h"
 
 #define MAXPRIO 11
@@ -20,14 +23,14 @@
 struct state	*states[MAXSTATES];
 struct action	*actions[MAXSTATES];
 struct mnems	patterns[MAXSTATES];
-int higheststate = 0;			/* Highest state yet allocated */
-struct idf *ops;			/* Chained list of all ops */
-int longestpattern = 0;
-int nerrors = 0;
+int		higheststate = 0;	/* Highest state yet allocated */
+struct idf	*ops;			/* Chained list of all ops */
+int		longestpattern = 0;
+int		nerrors = 0;
 
-static int lencurrpatt;
-static int lenthisrepl;
-static int currentstate;		/* Current state of dfa */
+static int	lencurrpatt;
+static int	lenthisrepl;
+static int	currentstate;		/* Current state of dfa */
 }
 
 input	: /* empty */
@@ -101,9 +104,6 @@ restriction(int argtype; struct exp_node **test;)
 		[ optrelop(&relop) exp(1,test)
 			{
 			*test = mknode(relop,mkleaf(PATARG,lencurrpatt),*test);
-			*test = mknode(LOGAND,
-				mkleaf(DEFINED,lencurrpatt),
-				*test);
 			}
 		| DEFINED
 			{
@@ -280,7 +280,7 @@ argno(int *val;)
 		{
 		*val = lastintval;
 		if(lastintval<0 || (lastintval>lencurrpatt)) {
-			fprint(STDERR ,"Illegal $%d on line %d\n",
+			fprintf(stderr ,"Illegal $%d on line %d\n",
 					lastintval,linenum);
 			nerrors++;
 		}
@@ -390,7 +390,7 @@ dotransition(state, mnem, mnem_list, lenlist)
 		p=(struct state *)Malloc(sizeof(struct state));
 		p->op=mnem;
 		if(++higheststate>MAXSTATES) {
-			fprint("Parser: More than %s states\n",MAXSTATES);
+			fprintf(stderr,"Parser: More than %s states\n",MAXSTATES);
 			sys_stop(S_EXIT);
 		}
 		p->goto_state= higheststate;
@@ -473,12 +473,12 @@ LLmessage(insertedtok)
 	int insertedtok;
 {
 	nerrors++;
-	fprint(STDERR,"parser: syntax error on line %d: ",linenum);
+	fprintf(stderr,"parser: syntax error on line %d: ",linenum);
 	if(insertedtok) {
-		fprint(STDERR,"Inserted token %d\n",insertedtok);
+		fprintf(stderr,"Inserted token %d\n",insertedtok);
 		yyless(0);
 	}
-	else fprint(STDERR,"Deleted token %d\n",LLsymb);
+	else fprintf(stderr,"Deleted token %d\n",LLsymb);
 }
 
 main() {
@@ -487,7 +487,7 @@ main() {
 	patterns[0].m_len = 0;
 	parser();
 	if(nerrors) {
-		fprint(STDERR,"%d errors detected\n",nerrors);
+		fprintf(stderr,"%d errors detected\n",nerrors);
 		sys_stop(S_EXIT);
 	}
 	outputnopt();
diff --git a/modules/src/em_opt/parser.h b/modules/src/em_opt/parser.h
index 6df6ef325..d07d20483 100644
--- a/modules/src/em_opt/parser.h
+++ b/modules/src/em_opt/parser.h
@@ -1,8 +1,7 @@
 /* $Header$ */
+#include <stdio.h>
 #include <system.h>
 
-#define NULL 0
-
 /* type of arguments expected by each instruction */
 #define NOARG  1
 #define CST    2
@@ -73,24 +72,24 @@ struct state {
 #define MAXPATTERN	20
 
 /* Parser globals */
-extern struct state *states[MAXSTATES];
-extern struct action *actions[MAXSTATES];
-extern struct mnems patterns[MAXSTATES];
-extern int higheststate;		/* Highest state yet allocated */
-extern struct idf *ops;			/* Chained list of all ops */
-extern int longestpattern;
-extern int nerrors;
-extern File *ofile;
+extern struct state	*states[MAXSTATES];
+extern struct action	*actions[MAXSTATES];
+extern struct mnems	patterns[MAXSTATES];
+extern int		higheststate;	/* Highest state yet allocated */
+extern struct idf	*ops;		/* Chained list of all ops */
+extern int		longestpattern;
+extern int		nerrors;
+extern FILE		*ofile;
 
 /* Lexical analyser globals */
-extern struct idf *opval;	/* opcode of returned OPCODE*/
-extern int lastintval;		/* value of last integer seen */
-extern int	linenum;	/*line number of input file*/
+extern struct idf	*opval;		/* opcode of returned OPCODE*/
+extern int		lastintval;	/* value of last integer seen */
+extern int		linenum;	/*line number of input file*/
 
 /* Functions not returning int */
-char *Malloc();
-struct exp_node *mknode();
-struct exp_node *mkleaf();
-struct exp_node *combinetests();
-struct mnem_list *addelem();
-struct mnem_elem **constructlist();
+char			*Malloc();
+struct exp_node		*mknode();
+struct exp_node		*mkleaf();
+struct exp_node 	*combinetests();
+struct mnem_list	*addelem();
+struct mnem_elem	**constructlist();
diff --git a/modules/src/em_opt/pseudo.r b/modules/src/em_opt/pseudo.r
index a758cb4b7..fecb834f1 100644
--- a/modules/src/em_opt/pseudo.r
+++ b/modules/src/em_opt/pseudo.r
@@ -1,174 +1,183 @@
 df_dlb	| label:l	|
 	FLUSHDFA();
-	O_df_dlb(l);
+	C_df_dlb(l);
 df_dnam	| char *:s	|
 	FLUSHDFA();
-	O_df_dnam(s);
+	C_df_dnam(s);
 pro	| char *:s arith:l	|
 	FLUSHDFA();
-	O_pro(s,l);
+	C_pro(s,l);
 pro_narg	| char *:s	|
 	FLUSHDFA();
-	O_pro_narg(s);
+	C_pro_narg(s);
 end	| arith:l	|
 	FLUSHDFA();
-	O_end(l);
+	C_end(l);
 end_narg	|	|
 	FLUSHDFA();
-	O_end_narg();
+	C_end_narg();
 exa_dnam	| char *:s	|
 	FLUSHDFA();
-	O_exa_dnam(s);
+	C_exa_dnam(s);
 exa_dlb	| label:l	|
 	FLUSHDFA();
-	O_exa_dlb(l);
+	C_exa_dlb(l);
 exp	| char *:s	|
 	FLUSHDFA();
-	O_exp(s);
+	C_exp(s);
 ina_dnam	| char *:s	|
 	FLUSHDFA();
-	O_ina_dnam(s);
+	C_ina_dnam(s);
 ina_dlb	| label:l	|
 	FLUSHDFA();
-	O_ina_dlb(l);
+	C_ina_dlb(l);
 inp	| char *:s	|
 	FLUSHDFA();
-	O_inp(s);
+	C_inp(s);
 bss_cst	| arith:n arith:w int:i	|
 	FLUSHDFA();
-	O_bss_cst(n,w,i);
+	C_bss_cst(n,w,i);
 bss_icon	| arith:n char *:s arith:sz int:i	|
 	FLUSHDFA();
-	O_bss_icon(n,s,sz,i);
+	C_bss_icon(n,s,sz,i);
 bss_ucon	| arith:n char *:s arith:sz int:i	|
 	FLUSHDFA();
-	O_bss_ucon(n,s,sz,i);
+	C_bss_ucon(n,s,sz,i);
 bss_fcon	| arith:n char *:s arith:sz int:i	|
 	FLUSHDFA();
-	O_bss_fcon(n,s,sz,i);
+	C_bss_fcon(n,s,sz,i);
 bss_dnam	| arith:n char *:s arith:offs int:i	|
 	FLUSHDFA();
-	O_bss_dnam(n,s,offs,i);
+	C_bss_dnam(n,s,offs,i);
 bss_dlb	| arith:n label:l arith:offs int:i	|
 	FLUSHDFA();
-	O_bss_dlb(n,l,offs,i);
+	C_bss_dlb(n,l,offs,i);
 bss_ilb	| arith:n label:l int:i	|
 	FLUSHDFA();
-	O_bss_ilb(n,l,i);
+	C_bss_ilb(n,l,i);
 bss_pnam	| arith:n char *:s int:i	|
 	FLUSHDFA();
-	O_bss_pnam(n,s,i);
+	C_bss_pnam(n,s,i);
 hol_cst	| arith:n arith:w int:i	|
 	FLUSHDFA();
-	O_hol_cst(n,w,i);
+	C_hol_cst(n,w,i);
 hol_icon	| arith:n char *:s arith:sz int:i	|
 	FLUSHDFA();
-	O_hol_icon(n,s,sz,i);
+	C_hol_icon(n,s,sz,i);
 hol_ucon	| arith:n char *:s arith:sz int:i	|
 	FLUSHDFA();
-	O_hol_ucon(n,s,sz,i);
+	C_hol_ucon(n,s,sz,i);
 hol_fcon	| arith:n char *:s arith:sz int:i	|
 	FLUSHDFA();
-	O_hol_fcon(n,s,sz,i);
+	C_hol_fcon(n,s,sz,i);
 hol_dnam	| arith:n char *:s arith:offs int:i	|
 	FLUSHDFA();
-	O_hol_dnam(n,s,offs,i);
+	C_hol_dnam(n,s,offs,i);
 hol_dlb	| arith:n label:l arith:offs int:i	|
 	FLUSHDFA();
-	O_hol_dlb(n,l,offs,i);
+	C_hol_dlb(n,l,offs,i);
 hol_ilb	| arith:n label:l int:i	|
 	FLUSHDFA();
-	O_hol_ilb(n,l,i);
+	C_hol_ilb(n,l,i);
 hol_pnam	| arith:n char *:s int:i	|
 	FLUSHDFA();
-	O_hol_pnam(n,s,i);
+	C_hol_pnam(n,s,i);
 con_cst	| arith:l	|
 	FLUSHDFA();
-	O_con_cst(l);
+	C_con_cst(l);
 con_icon	| char *:val arith:siz	|
 	FLUSHDFA();
-	O_con_icon(val,siz);
+	C_con_icon(val,siz);
 con_ucon	| char *:val arith:siz	|
 	FLUSHDFA();
-	O_con_ucon(val,siz);
+	C_con_ucon(val,siz);
 con_fcon	| char *:val arith:siz	|
 	FLUSHDFA();
-	O_con_fcon(val,siz);
+	C_con_fcon(val,siz);
 con_scon	| char *:str arith:siz	|
 	FLUSHDFA();
-	O_con_scon(str,siz);
+	C_con_scon(str,siz);
 con_dnam	| char *:str arith:val	|
 	FLUSHDFA();
-	O_con_dnam(str,val);
+	C_con_dnam(str,val);
 con_dlb	| label:l arith:val	|
 	FLUSHDFA();
-	O_con_dlb(l,val);
+	C_con_dlb(l,val);
 con_ilb	| label:l	|
 	FLUSHDFA();
-	O_con_ilb(l);
+	C_con_ilb(l);
 con_pnam	| char *:str	|
 	FLUSHDFA();
-	O_con_pnam(str);
+	C_con_pnam(str);
 rom_cst	| arith:l	|
 	FLUSHDFA();
-	O_rom_cst(l);
+	C_rom_cst(l);
 rom_icon	| char *:val arith:siz	|
 	FLUSHDFA();
-	O_rom_icon(val,siz);
+	C_rom_icon(val,siz);
 rom_ucon	| char *:val arith:siz	|
 	FLUSHDFA();
-	O_rom_ucon(val,siz);
+	C_rom_ucon(val,siz);
 rom_fcon	| char *:val arith:siz	|
 	FLUSHDFA();
-	O_rom_fcon(val,siz);
+	C_rom_fcon(val,siz);
 rom_scon	| char *:str arith:siz	|
 	FLUSHDFA();
-	O_rom_scon(str,siz);
+	C_rom_scon(str,siz);
 rom_dnam	| char *:str arith:val	|
 	FLUSHDFA();
-	O_rom_dnam(str,val);
+	C_rom_dnam(str,val);
 rom_dlb	| label:l arith:val	|
 	FLUSHDFA();
-	O_rom_dlb(l,val);
+	C_rom_dlb(l,val);
 rom_ilb	| label:l	|
 	FLUSHDFA();
-	O_rom_ilb(l);
+	C_rom_ilb(l);
 rom_pnam	| char *:str	|
 	FLUSHDFA();
-	O_rom_pnam(str);
+	C_rom_pnam(str);
 cst	| arith:l	|
 	FLUSHDFA();
-	O_cst(l);
+	C_cst(l);
 icon	| char *:val arith:siz	|
 	FLUSHDFA();
-	O_icon(val,siz);
+	C_icon(val,siz);
 ucon	| char *:val arith:siz	|
 	FLUSHDFA();
-	O_ucon(val,siz);
+	C_ucon(val,siz);
 fcon	| char *:val arith:siz	|
 	FLUSHDFA();
-	O_fcon(val,siz);
+	C_fcon(val,siz);
 scon	| char *:str arith:siz	|
 	FLUSHDFA();
-	O_scon(str,siz);
+	C_scon(str,siz);
 dnam	| char *:str arith:val	|
 	FLUSHDFA();
-	O_dnam(str,val);
+	C_dnam(str,val);
 dlb	| label:l arith:val	|
 	FLUSHDFA();
-	O_dlb(l,val);
+	C_dlb(l,val);
 ilb	| label:l	|
 	FLUSHDFA();
-	O_ilb(l);
+	C_ilb(l);
 pnam	| char *:str	|
 	FLUSHDFA();
-	O_pnam(str);
+	C_pnam(str);
 mes_begin	| int:ms	|
 	FLUSHDFA();
-	O_mes_begin(ms);
+	C_mes_begin(ms);
 mes_end	|	|
 	FLUSHDFA();
-	O_mes_end();
+	C_mes_end();
 exc	| arith:c1 arith:c2	|
 	FLUSHDFA();
-	O_exc(c1,c2);
+	C_exc(c1,c2);
+insertpart	| int:id	|
+	FLUSHDFA();
+	C_insertpart(id);
+beginpart	| int:id	|
+	FLUSHDFA();
+	C_beginpart(id);
+endpart	| int:id	|
+	FLUSHDFA();
+	C_endpart(id);
diff --git a/modules/src/em_opt/syntax.l b/modules/src/em_opt/syntax.l
index be7dcbce2..5ed6bfbd0 100644
--- a/modules/src/em_opt/syntax.l
+++ b/modules/src/em_opt/syntax.l
@@ -3,9 +3,9 @@
 #include "Lpars.h"
 #include "parser.h"
 
-struct idf *opval;	/* opcode of returned OPCODE*/
-int lastintval;		/* value of last integer seen */
-int linenum = 1;	/*current line number of input file*/
+struct idf	*opval;		/* opcode of returned OPCODE*/
+int		lastintval;	/* value of last integer seen */
+int		linenum = 1;	/*current line number of input file*/
 %}
 %%
 sfit		return(SFIT);
@@ -19,7 +19,7 @@ samesign	return(SAMESIGN);
 sameext		return(SAMEEXT);
 samenam		return(SAMENAM);
 offset		return(OFFSET);
-[a-z]*		{
+[a-z][a-z][a-z]	{
 		opval = str2idf(yytext,0);
 		return(OPCODE);
 		}