Index: doc/theses/aaron_moss/phd/.gitignore
===================================================================
--- doc/theses/aaron_moss/phd/.gitignore	(revision a42a6542b4369835501abbde87c5fd815d0f0d21)
+++ doc/theses/aaron_moss/phd/.gitignore	(revision f8b69da714038baa1174cd4bf59e8889ef5225bc)
@@ -1,2 +1,3 @@
+templates/
 thesis.pdf
 thesis.aux
@@ -6,3 +7,3 @@
 thesis.out
 thesis.toc
-templates/
+thesis.lot
Index: doc/theses/aaron_moss/phd/Makefile
===================================================================
--- doc/theses/aaron_moss/phd/Makefile	(revision a42a6542b4369835501abbde87c5fd815d0f0d21)
+++ doc/theses/aaron_moss/phd/Makefile	(revision f8b69da714038baa1174cd4bf59e8889ef5225bc)
@@ -6,5 +6,15 @@
 AUX = ${BASE}.aux ${BASE}.bbl ${BASE}.blg ${BASE}.log ${BASE}.out ${BASE}.toc
 
-.PHONY : all rebuild-refs clean
+SOURCES = ${addsuffix .tex, \
+thesis \
+frontpgs \
+introduction \
+background \
+type-environment \
+resolution-heuristics \
+conclusion \
+}
+
+.PHONY : all rebuild-refs clean wc
 
 all : ${DOCUMENT}
@@ -13,9 +23,12 @@
 	@rm -frv ${DOCUMENT} ${AUX}
 
-${DOCUMENT} :
+wc :
+	wc ${SOURCES}
+
+${DOCUMENT} : ${SOURCES}
 	${LATEX} ${BASE}
 	${LATEX} ${BASE}
 
-rebuild-refs : 
+rebuild-refs : ${SOURCES} aaron-thesis.bib
 	${LATEX} ${BASE}
 	${BIBTEX} ${BASE}
Index: doc/theses/aaron_moss/phd/aaron-thesis.bib
===================================================================
--- doc/theses/aaron_moss/phd/aaron-thesis.bib	(revision a42a6542b4369835501abbde87c5fd815d0f0d21)
+++ doc/theses/aaron_moss/phd/aaron-thesis.bib	(revision f8b69da714038baa1174cd4bf59e8889ef5225bc)
@@ -36,4 +36,26 @@
 }
 
+@article{Buhr94a,
+    keywords	= {assignment, parameter passing, multiple assignment},
+    contributer	= {pabuhr@plg},
+    author	= {P. A. Buhr and David Till and C. R. Zarnke},
+    title	= {Assignment as the Sole Means of Updating Objects},
+    journal	= spe,
+    month	= sep,
+    year	= 1994,
+    volume	= 24,
+    number	= 9,
+    pages	= {835-870},
+}
+
+@mastersthesis{Delisle18,
+    author	= {Thierry Delisle },
+    title	= {Concurrency in \textsf{C}$\mathbf{\forall}$},
+    school	= {School of Computer Science, University of Waterloo},
+    year	= 2018,
+    address	= {Waterloo, Ontario, Canada, N2L 3G1},
+    note	= {\href{https://uwspace.uwaterloo.ca/handle/10012/12888}{https://\-uwspace.uwaterloo.ca/\-handle/\-10012/\-12888}},
+}
+
 @phdthesis{Ditchfield92,
     keywords	= {C, parametric polymorphism, overloading},
@@ -56,2 +78,20 @@
     note	= {Accepted, to appear},
 }
+
+@mastersthesis{Schluntz17,
+    keywords 	= {constructors, destructors, tuples},
+    author	= {Robert Schluntz},
+    title	= {Resource Management and Tuples in \textsf{C}$\mathbf{\forall}$},
+    school	= {School of Computer Science, University of Waterloo},
+    year	= 2017,
+    address	= {Waterloo, Ontario, Canada, N2L 3G1},
+    note	= {\href{https://uwspace.uwaterloo.ca/handle/10012/11830}{https://\-uwspace.uwaterloo.ca/\-handle/\-10012/\-11830}},
+}
+
+@misc{TIOBE,
+    contributer	= {pabuhr@plg},
+    key		= {TIOBE Index},
+    title	= {{TIOBE} Index},
+    howpublished= {\href{http://www.tiobe.com/tiobe_index}{http://\-www.tiobe.com/\-tiobe\_index}},
+    optnote	= {Accessed: 2018-08},
+}
Index: doc/theses/aaron_moss/phd/background.tex
===================================================================
--- doc/theses/aaron_moss/phd/background.tex	(revision a42a6542b4369835501abbde87c5fd815d0f0d21)
+++ doc/theses/aaron_moss/phd/background.tex	(revision f8b69da714038baa1174cd4bf59e8889ef5225bc)
@@ -1,3 +1,13 @@
 \chapter{Background}
 
-This is the background. Basically, need to cite Ditchfield\cite{Ditchfield92}, Bilson\cite{Bilson03}, and Moss~\etal\cite{Moss18}
+\CFA{} adds a number of features to C, some of them providing significant increases to the expressive power of the language, but all designed to maintain the existing procedural programming paradigm of C and to be as orthogonal as possible with each other. 
+To provide background for the contributions in subsequent chapters, this chapter provides a summary of the features of \CFA{} at the time this work was conducted.
+
+The core design of \CFA{} is laid out in Glen Ditchfield's 1992 PhD thesis, \emph{Contextual Polymorphism}\cite{Ditchfield92}; in that thesis, Ditchfield lays out the theoretical underpinnings of the \CFA{} polymorphism model. 
+Building on Ditchfield's design for contextual polymorphism as well as KW-C\cite{Buhr94a}, an earlier set of (largely syntactic) extensions to C, Richard Bilson\cite{Bilson03} built the first version of the \CFA{} compiler, \CFACC{}, in the early 2000's. 
+This early \CFACC{} provided basic functionality, but incorporated a number of poor algorithmic choices due to a rushed implementation time frame, and as such lacked the runtime performance required for practical use; this thesis is substantially concerned with rectifying those deficits. 
+
+The \CFA{} project was revived in 2015 with the intention of building a production-ready language and compiler; at the time of this writing, both \CFA{} and \CFACC{} have been under active development continuously since. 
+As this development has been proceeding concurrently with the work described in this thesis, the state of \CFA{} has been somewhat of a moving target; however, Moss~\etal\cite{Moss18} provides a reasonable summary of the current design of \CFA{}. 
+Notable features added during this period include generic types[Chapter~\ref{generic-chap}], constructors and destructors\cite{Schluntz17}, improved support for tuples\cite{Schluntz17}, reference types\cite{Moss18}, first-class concurrent and parallel programming support\cite{Delisle18}, as well as numerous pieces of syntactic sugar and the start of an idiomatic standard library\cite{Moss18}.
+
Index: doc/theses/aaron_moss/phd/frontpgs.tex
===================================================================
--- doc/theses/aaron_moss/phd/frontpgs.tex	(revision a42a6542b4369835501abbde87c5fd815d0f0d21)
+++ doc/theses/aaron_moss/phd/frontpgs.tex	(revision f8b69da714038baa1174cd4bf59e8889ef5225bc)
@@ -153,8 +153,8 @@
 % L I S T   O F   T A B L E S
 % ---------------------------
-% \addcontentsline{toc}{chapter}{List of Tables}
-% \listoftables
-% \cleardoublepage
-% \phantomsection		% allows hyperref to link to the correct page
+\addcontentsline{toc}{chapter}{List of Tables}
+\listoftables
+\cleardoublepage
+\phantomsection		% allows hyperref to link to the correct page
 
 % L I S T   O F   F I G U R E S
Index: doc/theses/aaron_moss/phd/generic-types.tex
===================================================================
--- doc/theses/aaron_moss/phd/generic-types.tex	(revision a42a6542b4369835501abbde87c5fd815d0f0d21)
+++ doc/theses/aaron_moss/phd/generic-types.tex	(revision f8b69da714038baa1174cd4bf59e8889ef5225bc)
@@ -1,3 +1,4 @@
 \chapter{Generic Types}
+\label{generic-chap}
 
 Talk about generic types. Pull from Moss~\etal\cite{Moss18}.
Index: doc/theses/aaron_moss/phd/introduction.tex
===================================================================
--- doc/theses/aaron_moss/phd/introduction.tex	(revision a42a6542b4369835501abbde87c5fd815d0f0d21)
+++ doc/theses/aaron_moss/phd/introduction.tex	(revision f8b69da714038baa1174cd4bf59e8889ef5225bc)
@@ -1,3 +1,37 @@
 \chapter{Introduction}
 
-This is the introduction.
+The C programming language has had a wide-ranging impact on the design of software and programming languages. 
+In the 30 years since its first standardization, it has consistently been one of the most popular programming languages, with millions of lines of C code still in active use, and tens of thousands of trained programmers producing it. The TIOBE index\cite{TIOBE} tracks popularity of programming languages over time, and C has never dropped below second place:
+
+\begin{table}
+\label{tiobe-table}
+\caption[TIOBE index over time]{Current top 5 places in the TIOBE index averaged over years}
+
+\centering
+\begin{tabular}{@{}cccccccc@{}}
+	& 2018	& 2013	& 2008	& 2003	& 1998	& 1993	& 1988	\\
+Java		& 1		& 2		& 1		& 1		& 18	& --	& --	\\
+\textbf{C}	& \textbf{2} & \textbf{1} & \textbf{2} & \textbf{2} & \textbf{1} & \textbf{1} & \textbf{1} \\
+\CC{}		& 3		& 4		& 3		& 3		& 2		& 2		& 5		\\
+Python		& 4		& 7		& 6		& 11	& 22	& 17	& --	\\
+\Csharp{}	& 5		& 5		& 7		& 8		& --	& --	& --	\\
+\end{tabular}
+\end{table}
+
+The impact of C on programming language design is also obvious from Table~\ref{tiobe-table}; with the exception of Python, all of the top five languages use C-like syntax and procedural control structures. 
+\CC is even a largely backwards-compatible extension of C, with development dating back nearly as far as C itself. 
+Though its lasting popularity and wide impact on programming language design point to the continued relevance of C, they also highlight the widespread desire of programmers for languages with more expressive power and programmer-friendly features; accommodating both low-impact maintenance of legacy C code and low-effort development of the software of the future is a difficult task for a single programming language.
+
+\CFA{}\footnote{Pronounced ``C-for-all'', and written \CFA{} or \CFL{}.} is an evolutionary modernization of the C programming language which aims to fulfill both these ends well. 
+\CFA{} both fixes existing design problems and adds multiple new features to C, including name overloading, user-defined operators, parametric-polymorphic routines, and type constructors and destructors, among others. 
+The new features make \CFA{} more powerful and expressive than C, while maintaining strong backward-compatibility with both C code and the procedural paradigm expected by C programmers. 
+However, these new features do impose a compile-time cost, particularly in the expression resolver, which must evaluate the typing rules of a significantly more complex type-system.
+
+This thesis is focused on making \CFA{} a more powerful and expressive language, both by adding new features to the \CFA{} type system and ensuring that both added and existing features can be efficiently implemented in \CFACC{}, the \CFA{} reference compiler. 
+Particular contributions of this work include design and implementation of 
+parametric-polymorphic (``generic'') types in a manner compatible with the existing polymorphism design of \CFA{} (Chapter~\ref{generic-chap}), a type environment data structure based on a novel variant of the union-find algorithm (Chapter~\ref{env-chap}), and a new expression resolution algorithm designed to quickly locate the optimal declarations for a \CFA{} declaration (Chapter~\ref{resolution-chap}). 
+This expression resolution algorithm was designed with the aid of a purpose-built prototype system which encapsulates the essential aspects of the \CFA{} type system without incurring the technical debt of the existing system or the friction-inducing necessity of maintaining a working compiler; the goal of this prototype system was to discover effective heuristics to avoid performing unnecessary work in the process of locating the optimal \CFA{} expression resolution.
+
+Though the direction and validation of this work was fairly narrowly focused on the \CFA{} programming language, the tools used and results obtained should be of interest to a wider compiler and programming language design community. 
+In particular, with the addition of \emph{concepts} in \CCtwenty{}, conforming \CC{} compilers must support a model of type assertions very similar to that in \CFA{}, and the algorithmic techniques used in the expression resolution algorithm presented here may prove useful. 
+Type environments are also widely modelled in compiler implementations, particularly of functional languages, though also increasingly commonly in other languages (such as Rust) which also perform type inference; the type environment presented here may be useful to those language implementers.
Index: doc/theses/aaron_moss/phd/macros.tex
===================================================================
--- doc/theses/aaron_moss/phd/macros.tex	(revision a42a6542b4369835501abbde87c5fd815d0f0d21)
+++ doc/theses/aaron_moss/phd/macros.tex	(revision f8b69da714038baa1174cd4bf59e8889ef5225bc)
@@ -3,5 +3,14 @@
 
 \newcommand{\CFAIcon}{\textsf{C}\raisebox{\depth}{\rotatebox{180}{\textsf{A}}}} % Cforall symbolic name
-\newcommand{\CFA}{\protect\CFAIcon}		% safe for section/caption
+\newcommand{\CFA}{\protect\CFAIcon}	% safe for section/caption
+\newcommand{\CFL}{\textrm{Cforall}} % Cforall symbolic name
+\newcommand{\CFACC}{\texttt{cfa-cc}} % Cforall compiler
+\newcommand{\Celeven}{\textrm{C11}} % C11 symbolic name
+\newcommand{\CC}{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}} % C++ symbolic name
+\newcommand{\CCeleven}{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}11} % C++11 symbolic name
+\newcommand{\CCfourteen}{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}14} % C++14 symbolic name
+\newcommand{\CCseventeen}{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}17} % C++17 symbolic name
+\newcommand{\CCtwenty}{\textrm{C}\kern-.1em\hbox{+\kern-.25em+}20} % C++20 symbolic name
+\newcommand{\Csharp}{C\raisebox{-0.7ex}{\Large$^\sharp$}} % C# symbolic name
 
 \newcommand{\ie}{\textit{i.e.}}
@@ -9,2 +18,4 @@
 \newcommand{\etc}{\textit{etc.}}
 \newcommand{\etal}{\textit{et~al.}}
+
+\newcommand{\TODO}[1]{\textbf{TODO:} \textit{#1}}
Index: doc/theses/aaron_moss/phd/resolution-heuristics.tex
===================================================================
--- doc/theses/aaron_moss/phd/resolution-heuristics.tex	(revision a42a6542b4369835501abbde87c5fd815d0f0d21)
+++ doc/theses/aaron_moss/phd/resolution-heuristics.tex	(revision f8b69da714038baa1174cd4bf59e8889ef5225bc)
@@ -1,3 +1,4 @@
 \chapter{Resolution Heuristics}
+\label{resolution-chap}
 
 Talk about the resolution heuristics. This is the bulk of the thesis.
Index: doc/theses/aaron_moss/phd/type-environment.tex
===================================================================
--- doc/theses/aaron_moss/phd/type-environment.tex	(revision a42a6542b4369835501abbde87c5fd815d0f0d21)
+++ doc/theses/aaron_moss/phd/type-environment.tex	(revision f8b69da714038baa1174cd4bf59e8889ef5225bc)
@@ -1,3 +1,4 @@
 \chapter{Type Environment}
+\label{env-chap}
 
 Talk about the type environment data structure. Pull from your presentation.
Index: libcfa/prelude/Makefile.am
===================================================================
--- libcfa/prelude/Makefile.am	(revision a42a6542b4369835501abbde87c5fd815d0f0d21)
+++ libcfa/prelude/Makefile.am	(revision f8b69da714038baa1174cd4bf59e8889ef5225bc)
@@ -55,5 +55,5 @@
 # create forward declarations for cfa builtins
 builtins.cf : builtins.c ${CC}
-	${AM_V_GEN}gcc ${AM_CFLAGS} -E -P ${<} -o ${@} -MD -MP -MF $(DEPDIR)/builtins.Po
+	${AM_V_GEN}cfa ${AM_CFLAGS} -E -P ${<} -o ${@} -MD -MP -MF $(DEPDIR)/builtins.Po
 	${AM_V_at}sed -i 's/builtins.o/builtins.cf/g' $(DEPDIR)/builtins.Po
 
Index: libcfa/prelude/Makefile.in
===================================================================
--- libcfa/prelude/Makefile.in	(revision a42a6542b4369835501abbde87c5fd815d0f0d21)
+++ libcfa/prelude/Makefile.in	(revision f8b69da714038baa1174cd4bf59e8889ef5225bc)
@@ -510,5 +510,5 @@
 # create forward declarations for cfa builtins
 builtins.cf : builtins.c ${CC}
-	${AM_V_GEN}gcc ${AM_CFLAGS} -E -P ${<} -o ${@} -MD -MP -MF $(DEPDIR)/builtins.Po
+	${AM_V_GEN}cfa ${AM_CFLAGS} -E -P ${<} -o ${@} -MD -MP -MF $(DEPDIR)/builtins.Po
 	${AM_V_at}sed -i 's/builtins.o/builtins.cf/g' $(DEPDIR)/builtins.Po
 
Index: src/GenPoly/Lvalue.cc
===================================================================
--- src/GenPoly/Lvalue.cc	(revision a42a6542b4369835501abbde87c5fd815d0f0d21)
+++ src/GenPoly/Lvalue.cc	(revision f8b69da714038baa1174cd4bf59e8889ef5225bc)
@@ -353,4 +353,6 @@
 			Type * destType = castExpr->result;
 			Type * srcType = castExpr->arg->result;
+			assertf( destType, "Cast to no type in: %s", toCString( castExpr ) );
+			assertf( srcType, "Cast from no type in: %s", toCString( castExpr ) );
 			int depth1 = destType->referenceDepth();
 			int depth2 = srcType->referenceDepth();
Index: src/Parser/parser.yy
===================================================================
--- src/Parser/parser.yy	(revision a42a6542b4369835501abbde87c5fd815d0f0d21)
+++ src/Parser/parser.yy	(revision f8b69da714038baa1174cd4bf59e8889ef5225bc)
@@ -1310,7 +1310,7 @@
 
 handler_clause:
-	handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement pop
+	handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement
 		{ $$ = new StatementNode( build_catch( $1, $4, $6, $8 ) ); }
-	| handler_clause handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement pop
+	| handler_clause handler_key '(' push exception_declaration pop handler_predicate_opt ')' compound_statement
 		{ $$ = (StatementNode *)$1->set_last( new StatementNode( build_catch( $2, $5, $7, $9 ) ) ); }
 	;
Index: src/Virtual/ExpandCasts.cc
===================================================================
--- src/Virtual/ExpandCasts.cc	(revision a42a6542b4369835501abbde87c5fd815d0f0d21)
+++ src/Virtual/ExpandCasts.cc	(revision f8b69da714038baa1174cd4bf59e8889ef5225bc)
@@ -147,16 +147,16 @@
 				//		)
 				//	),
-			new UntypedExpr( new NameExpr( "__cfa__virtual_cast" ), {
+			new ApplicationExpr( VariableExpr::functionPointer( vcast_decl ), {
 					new CastExpr(
 						new AddressExpr( new VariableExpr( table ) ),
 						pointer_to_pvt(1)
-						),
+					),
 					new CastExpr(
 						castExpr->get_arg(),
 						pointer_to_pvt(2)
-						)
-				} ),
+					)
+			} ),
 			castExpr->get_result()->clone()
-			);
+		);
 
 		castExpr->set_arg( nullptr );
