Index: doc/theses/andrew_beach_MMath/Makefile
===================================================================
--- doc/theses/andrew_beach_MMath/Makefile	(revision 79e261b7c10e84cbd652f6b8e8a4ff0e7c196b4e)
+++ doc/theses/andrew_beach_MMath/Makefile	(revision f7066971a8d399395addd0fa9ee744a61ac3555b)
@@ -1,5 +1,5 @@
 ### Makefile for Andrew Beach's Masters Thesis
 
-DOC=thesis.pdf
+DOC=uw-thesis.pdf
 BUILD=out
 TEXSRC=$(wildcard *.tex)
@@ -7,5 +7,5 @@
 STYSRC=$(wildcard *.sty)
 CLSSRC=$(wildcard *.cls)
-TEXLIB= .:${BUILD}:
+TEXLIB= .:../../LaTeXmacros:${BUILD}:
 BIBLIB= .:../../bibliography
 
@@ -29,4 +29,5 @@
 	${LATEX} ${BASE}
 	${BIBTEX} ${BUILD}/${BASE}
+	${LATEX} ${BASE}
 	${GLOSSARY} ${BUILD}/${BASE}
 	${LATEX} ${BASE}
Index: doc/theses/andrew_beach_MMath/existing.tex
===================================================================
--- doc/theses/andrew_beach_MMath/existing.tex	(revision 79e261b7c10e84cbd652f6b8e8a4ff0e7c196b4e)
+++ doc/theses/andrew_beach_MMath/existing.tex	(revision f7066971a8d399395addd0fa9ee744a61ac3555b)
@@ -1,7 +1,10 @@
-\chapter{\CFA{} Existing Features}
+\chapter{\CFA Existing Features}
+
+\CFA (C-for-all)~\cite{Cforall} is an open-source project extending ISO C with modern safety and productivity features, while still ensuring backwards compatibility with C and its programmers.
+\CFA is designed to have an orthogonal feature-set based closely on the C programming paradigm (non-object-oriented) and these features can be added incrementally to an existing C code-base allowing programmers to learn \CFA on an as-needed basis.
 
 \section{Overloading and extern}
 Cforall has overloading, allowing multiple definitions of the same name to
-be defined.
+be defined.~\cite{Moss18}
 
 This also adds name mangling so that the assembly symbols are unique for
@@ -11,19 +14,19 @@
 
 The syntax for disabling mangling is:
-\begin{lstlisting}
+\begin{cfa}
 extern "C" {
     ...
 }
-\end{lstlisting}
+\end{cfa}
 
 To re-enable mangling once it is disabled the syntax is:
-\begin{lstlisting}
+\begin{cfa}
 extern "Cforall" {
     ...
 }
-\end{lstlisting}
+\end{cfa}
 
 Both should occur at the declaration level and effect all the declarations
-in \texttt{...}. Neither care about the state of mangling when they begin
+in @...@. Neither care about the state of mangling when they begin
 and will return to that state after the group is finished. So re-enabling
 is only used to nest areas of mangled and unmangled declarations.
@@ -31,8 +34,8 @@
 \section{References}
 \CFA adds references to C. These are auto-dereferencing pointers and use the
-same syntax as pointers except they use ampersand (\codeCFA{\&}) instead of
-the asterisk (\codeCFA{*}). They can also be constaint or mutable, if they
+same syntax as pointers except they use ampersand (@&@) instead of
+the asterisk (@*@). They can also be constaint or mutable, if they
 are mutable they may be assigned to by using the address-of operator
-(\codeCFA\&) which converts them into a pointer.
+(@&@) which converts them into a pointer.
 
 \section{Constructors and Destructors}
@@ -41,22 +44,22 @@
 functions with special names. The special names are used to define them and
 may be used to call the functions expicately. The \CFA special names are
-constructed by taking the tokens in the operators and putting \texttt{?} where
-the arguments would go. So multiplication is \texttt{?*?} while dereference
-is \texttt{*?}. This also make it easy to tell the difference between
-pre-fix operations (such as \texttt{++?}) and post-fix operations
-(\texttt{?++}).
-
-The special name for contructors is \texttt{?\{\}}, which comes from the
+constructed by taking the tokens in the operators and putting @?@ where
+the arguments would go. So multiplication is @?*?@ while dereference
+is @*?@. This also make it easy to tell the difference between
+pre-fix operations (such as @++?@) and post-fix operations
+(@?++@).
+
+The special name for contructors is @?{}@, which comes from the
 initialization syntax in C. The special name for destructors is
-\texttt{\^{}?\{\}}. % I don't like the \^{} symbol but $^\wedge$ isn't better.
+@^{}@. % I don't like the \^{} symbol but $^\wedge$ isn't better.
 
 Any time a type T goes out of scope the destructor matching
-\codeCFA{void ^?\{\}(T \&);} is called. In theory this is also true of
-primitive types such as \codeCFA{int}, but in practice those are no-ops and
+@void ^?{}(T &);@ is called. In theory this is also true of
+primitive types such as @int@, but in practice those are no-ops and
 are usually omitted for optimization.
 
 \section{Polymorphism}
 \CFA uses polymorphism to create functions and types that are defined over
-different types. \CFA polymorphic declarations serve the same role as \CPP
+different types. \CFA polymorphic declarations serve the same role as \CC
 templates or Java generics.
 
@@ -65,9 +68,9 @@
 except that you may use the names introduced by the forall clause in them.
 
-Forall clauses are written \codeCFA{forall( ... )} where \codeCFA{...} becomes
+Forall clauses are written @forall( ... )@ where @...@ becomes
 the list of polymorphic variables (local type names) and assertions, which
 repersent required operations on those types.
 
-\begin{lstlisting}
+\begin{cfa}
 forall(dtype T | { void do_once(T &); })
 void do_twice(T & value) {
@@ -75,5 +78,5 @@
     do_once(value);
 }
-\end{lstlisting}
+\end{cfa}
 
 A polymorphic function can be used in the same way normal functions are.
@@ -83,7 +86,7 @@
 the the call site.
 
-As an example, even if no function named \codeCFA{do_once} is not defined
-near the definition of \codeCFA{do_twice} the following code will work.
-\begin{lstlisting}
+As an example, even if no function named @do_once@ is not defined
+near the definition of @do_twice@ the following code will work.
+\begin{cfa}
 int quadruple(int x) {
     void do_once(int & y) {
@@ -93,10 +96,10 @@
     return x;
 }
-\end{lstlisting}
+\end{cfa}
 This is not the recommended way to implement a quadruple function but it
-does work. The complier will deduce that \codeCFA{do_twice}'s T is an
+does work. The complier will deduce that @do_twice@'s T is an
 integer from the argument. It will then look for a definition matching the
-assertion which is the \codeCFA{do_once} defined within the function. That
-function will be passed in as a function pointer to \codeCFA{do_twice} and
+assertion which is the @do_once@ defined within the function. That
+function will be passed in as a function pointer to @do_twice@ and
 called within it.
 
@@ -104,15 +107,15 @@
 traits which collect assertions into convenent packages that can then be used
 in assertion lists instead of all of their components.
-\begin{lstlisting}
+\begin{cfa}
 trait done_once(dtype T) {
     void do_once(T &);
 }
-\end{lstlisting}
+\end{cfa}
 
 After this the forall list in the previous example could instead be written
 with the trait instead of the assertion itself.
-\begin{lstlisting}
+\begin{cfa}
 forall(dtype T | done_once(T))
-\end{lstlisting}
+\end{cfa}
 
 Traits can have arbitrary number of assertions in them and are usually used to
@@ -124,5 +127,5 @@
 are now used in field declaractions instead of parameters and local variables.
 
-\begin{lstlisting}
+\begin{cfa}
 forall(dtype T)
 struct node {
@@ -130,7 +133,7 @@
     T * data;
 }
-\end{lstlisting}
-
-The \codeCFA{node(T)} is a use of a polymorphic structure. Polymorphic types
+\end{cfa}
+
+The @node(T)@ is a use of a polymorphic structure. Polymorphic types
 must be provided their polymorphic parameters.
 
@@ -140,8 +143,8 @@
 \section{Concurrency}
 
-\CFA has a number of concurrency features, \codeCFA{thread}s,
-\codeCFA{monitor}s and \codeCFA{mutex} parameters, \codeCFA{coroutine}s and
-\codeCFA{generator}s. The two features that interact with the exception system
-are \codeCFA{thread}s and \codeCFA{coroutine}s; they and their supporting
+\CFA has a number of concurrency features, @thread@s,
+@monitor@s and @mutex@ parameters, @coroutine@s and
+@generator@s. The two features that interact with the exception system
+are @thread@s and @coroutine@s; they and their supporting
 constructs will be described here.
 
@@ -154,16 +157,16 @@
 library.
 
-In \CFA coroutines are created using the \codeCFA{coroutine} keyword which
-works just like \codeCFA{struct} except that the created structure will be
-modified by the compiler to satify the \codeCFA{is_coroutine} trait.
+In \CFA coroutines are created using the @coroutine@ keyword which
+works just like @struct@ except that the created structure will be
+modified by the compiler to satify the @is_coroutine@ trait.
 
 These structures act as the interface between callers and the coroutine,
 the fields are used to pass information in and out. Here is a simple example
 where the single field is used to pass the next number in a sequence out.
-\begin{lstlisting}
+\begin{cfa}
 coroutine CountUp {
     unsigned int next;
 }
-\end{lstlisting}
+\end{cfa}
 
 The routine part of the coroutine is a main function for the coroutine. It
@@ -173,5 +176,5 @@
 function it continue from that same suspend statement instead of at the top
 of the function.
-\begin{lstlisting}
+\begin{cfa}
 void main(CountUp & this) {
     unsigned int next = 0;
@@ -182,5 +185,5 @@
     }
 }
-\end{lstlisting}
+\end{cfa}
 
 Control is passed to the coroutine with the resume function. This includes the
@@ -189,5 +192,5 @@
 return value is for easy access to communication variables. For example the
 next value from a count-up can be generated and collected in a single
-expression: \codeCFA{resume(count).next}.
+expression: @resume(count).next@.
 
 \subsection{Monitors and Mutex}
@@ -198,6 +201,6 @@
 parameters.
 
-Function parameters can have the \codeCFA{mutex} qualifiers on reference
-arguments, for example \codeCFA{void example(a_monitor & mutex arg);}. When the
+Function parameters can have the @mutex@ qualifiers on reference
+arguments, for example @void example(a_monitor & mutex arg);@. When the
 function is called it will acquire the lock on all of the mutex parameters.
 
@@ -214,5 +217,5 @@
 
 Threads are created like coroutines except the keyword is changed:
-\begin{lstlisting}
+\begin{cfa}
 thread StringWorker {
     const char * input;
@@ -225,5 +228,5 @@
     this.result = result;
 }
-\end{lstlisting}
+\end{cfa}
 The main function will start executing after the fork operation and continue
 executing until it is finished. If another thread joins with this one it will
@@ -233,5 +236,5 @@
 From the outside this is the creation and destruction of the thread object.
 Fork happens after the constructor is run and join happens before the
-destructor runs. Join also happens during the \codeCFA{join} function which
+destructor runs. Join also happens during the @join@ function which
 can be used to join a thread earlier. If it is used the destructor does not
 join as that has already been completed.
Index: doc/theses/andrew_beach_MMath/features.tex
===================================================================
--- doc/theses/andrew_beach_MMath/features.tex	(revision 79e261b7c10e84cbd652f6b8e8a4ff0e7c196b4e)
+++ doc/theses/andrew_beach_MMath/features.tex	(revision f7066971a8d399395addd0fa9ee744a61ac3555b)
@@ -54,8 +54,8 @@
 returns a reference to the virtual table instance. Defining this function
 also establishes the virtual type and virtual table pair to the resolver
-and promises that \codeCFA{exceptT} is a virtual type and a child of the
+and promises that @exceptT@ is a virtual type and a child of the
 base exception type.
 
-One odd thing about \codeCFA{get_exception_vtable} is that it should always
+One odd thing about @get_exception_vtable@ is that it should always
 be a constant function, returning the same value regardless of its argument.
 A pointer or reference to the virtual table instance could be used instead,
@@ -66,7 +66,7 @@
 
 Also note the use of the word ``promise" in the trait description. \CFA
-cannot currently check to see if either \codeCFA{exceptT} or
-\codeCFA{virtualT} match the layout requirements. Currently this is
-considered part of \codeCFA{get_exception_vtable}'s correct implementation.
+cannot currently check to see if either @exceptT@ or
+@virtualT@ match the layout requirements. Currently this is
+considered part of @get_exception_vtable@'s correct implementation.
 
 \begin{lstlisting}
@@ -92,6 +92,6 @@
 
 Finally there are three additional macros that can be used to refer to the
-these traits. They are \codeCFA{IS_EXCEPTION},
-\codeCFA{IS_TERMINATION_EXCEPTION} and \codeCFA{IS_RESUMPTION_EXCEPTION}.
+these traits. They are @IS_EXCEPTION@,
+@IS_TERMINATION_EXCEPTION@ and @IS_RESUMPTION_EXCEPTION@.
 Each takes the virtual type's name and, for polymorphic types only, the
 parenthesized list of polymorphic arguments. These do the name mangling to
@@ -113,5 +113,5 @@
 The expression must evaluate to a reference to a termination exception. A
 termination exception is any exception with a
-\codeCFA{void defaultTerminationHandler(T &);} (the default handler) defined
+@void defaultTerminationHandler(T &);@ (the default handler) defined
 on it. The handler is taken from the call sight with \CFA's trait system and
 passed into the exception system along with the exception itself.
@@ -169,5 +169,5 @@
 
 You can also re-throw the most recent termination exception with
-\codeCFA{throw;}. % This is terrible and you should never do it.
+@throw;@. % This is terrible and you should never do it.
 This can be done in a handler or any function that could be called from a
 handler.
@@ -193,5 +193,5 @@
 The result of EXPRESSION must be a resumption exception type. A resumption
 exception type is any type that satisfies the assertion
-\codeCFA{void defaultResumptionHandler(T &);} (the default handler). When the
+@void defaultResumptionHandler(T &);@ (the default handler). When the
 statement is executed the expression is evaluated and the result is thrown.
 
@@ -260,6 +260,6 @@
 \paragraph{Re-Throwing}
 
-You may also re-throw resumptions with a \codeCFA{throwResume;} statement.
-This can only be done from inside of a \codeCFA{catchResume} block.
+You may also re-throw resumptions with a @throwResume;@ statement.
+This can only be done from inside of a @catchResume@ block.
 
 Outside of any side effects of any code already run in the handler this will
@@ -269,5 +269,5 @@
 \section{Finally Clauses}
 
-A \codeCFA{finally} clause may be placed at the end of a try statement after
+A @finally@ clause may be placed at the end of a try statement after
 all the handler clauses. In the simply case, with no handlers, it looks like
 this:
@@ -294,6 +294,6 @@
 
 Because of this local control flow out of the finally block is forbidden.
-The compiler rejects uses of \codeCFA{break}, \codeCFA{continue},
-\codeCFA{fallthru} and \codeCFA{return} that would cause control to leave
+The compiler rejects uses of @break@, @continue@,
+@fallthru@ and @return@ that would cause control to leave
 the finally block. Other ways to leave the finally block - such as a long
 jump or termination - are much harder to check, at best requiring additional
@@ -307,5 +307,5 @@
 
 There is no special statement for starting a cancellation, instead you call
-the standard library function \codeCFA{cancel\_stack} which takes an exception.
+the standard library function @cancel\_stack@ which takes an exception.
 Unlike in a throw this exception is not used in control flow but is just there
 to pass information about why the cancellation happened.
@@ -323,6 +323,6 @@
 
 \item Thread Stack:
-Thread stacks are those created \codeCFA{thread} or otherwise satisfy the
-\codeCFA{is\_thread} trait.
+Thread stacks are those created @thread@ or otherwise satisfy the
+@is\_thread@ trait.
 
 Threads only have two structural points of communication that must happen,
@@ -333,9 +333,9 @@
 and wait for another thread to join with it. The other thread, when it joins,
 checks for a cancellation. If so it will throw the resumption exception
-\codeCFA{ThreadCancelled}.
-
-There is a difference here in how explicate joins (with the \codeCFA{join}
+@ThreadCancelled@.
+
+There is a difference here in how explicate joins (with the @join@
 function) and implicate joins (from a destructor call). Explicate joins will
-take the default handler (\codeCFA{defaultResumptionHandler}) from the context
+take the default handler (@defaultResumptionHandler@) from the context
 and use like a regular through does if the exception is not caught. The
 implicate join does a program abort instead.
@@ -349,6 +349,6 @@
 
 \item Coroutine Stack:
-Coroutine stacks are those created with \codeCFA{coroutine} or otherwise
-satisfy the \codeCFA{is\_coroutine} trait.
+Coroutine stacks are those created with @coroutine@ or otherwise
+satisfy the @is\_coroutine@ trait.
 
 A coroutine knows of two other coroutines, its starter and its last resumer.
@@ -356,8 +356,8 @@
 
 After the stack is unwound control goes to the last resumer.
-Resume will resume throw a \codeCFA{CoroutineCancelled} exception, which is
+Resume will resume throw a @CoroutineCancelled@ exception, which is
 polymorphic over the coroutine type and has a pointer to the coroutine being
 canceled and the canceling exception. The resume function also has an
-assertion that the \codeCFA{defaultResumptionHandler} for the exception. So it
+assertion that the @defaultResumptionHandler@ for the exception. So it
 will use the default handler like a regular throw.
 
Index: doc/theses/andrew_beach_MMath/future.tex
===================================================================
--- doc/theses/andrew_beach_MMath/future.tex	(revision 79e261b7c10e84cbd652f6b8e8a4ff0e7c196b4e)
+++ doc/theses/andrew_beach_MMath/future.tex	(revision f7066971a8d399395addd0fa9ee744a61ac3555b)
@@ -20,6 +20,6 @@
 
 \section{Additional Throws}
-Several other kinds of throws, beyond the termination throw (\codeCFA{throw}),
-the resumption throw (\codeCFA{throwResume}) and the re-throws, were considered.
+Several other kinds of throws, beyond the termination throw (@throw@),
+the resumption throw (@throwResume@) and the re-throws, were considered.
 None were as useful as the core throws but they would likely be worth
 revising.
@@ -114,5 +114,5 @@
 is no reason not to allow it. It is however a small improvement; giving a bit
 of flexibility to the user in what style they want to use.
-\item Enabling local control flow (by \codeCFA{break}, \codeCFA{return} and
+\item Enabling local control flow (by @break@, @return@ and
 similar statements) out of a termination handler. The current set-up makes
 this very difficult but the catch function that runs the handler after it has
Index: doc/theses/andrew_beach_MMath/implement.tex
===================================================================
--- doc/theses/andrew_beach_MMath/implement.tex	(revision 79e261b7c10e84cbd652f6b8e8a4ff0e7c196b4e)
+++ doc/theses/andrew_beach_MMath/implement.tex	(revision f7066971a8d399395addd0fa9ee744a61ac3555b)
@@ -9,5 +9,5 @@
 
 All of this is accessed through a field inserted at the beginning of every
-virtual type. Currently it is called \codeC{virtual_table} but it is not
+virtual type. Currently it is called @virtual_table@ but it is not
 ment to be accessed by the user. This field is a pointer to the type's
 virtual table instance. It is assigned once during the object's construction
@@ -40,6 +40,6 @@
 using that to calculate the mangled name of the parent's virtual table type.
 There are two special fields that are included like normal fields but have
-special initialization rules: the \codeC{size} field is the type's size and is
-initialized with a sizeof expression, the \codeC{align} field is the type's
+special initialization rules: the @size@ field is the type's size and is
+initialized with a sizeof expression, the @align@ field is the type's
 alignment and uses an alignof expression. The remaining fields are resolved
 to a name matching the field's name and type using the normal visibility
@@ -56,5 +56,5 @@
 The declarations include the virtual type definition and forward declarations
 of the virtual table instance, constructor, message function and
-\codeCFA{get_exception_vtable}. The definition includes the storage and
+@get_exception_vtable@. The definition includes the storage and
 initialization of the virtual table instance and the bodies of the three
 functions.
@@ -65,9 +65,9 @@
 from the per-instance information. The virtual table type and most of the
 functions are polymorphic so they are all part of the core. The virtual table
-instance and the \codeCFA{get_exception_vtable} function.
-
-Coroutines and threads need instances of \codeCFA{CoroutineCancelled} and
-\codeCFA{ThreadCancelled} respectively to use all of their functionality.
-When a new data type is declared with \codeCFA{coroutine} or \codeCFA{thread}
+instance and the @get_exception_vtable@ function.
+
+Coroutines and threads need instances of @CoroutineCancelled@ and
+@ThreadCancelled@ respectively to use all of their functionality.
+When a new data type is declared with @coroutine@ or @thread@
 the forward declaration for the instance is created as well. The definition
 of the virtual table is created at the definition of the main function.
@@ -79,5 +79,5 @@
 function.
 
-The function is \codeC{__cfa__virtual_cast} and it is implemented in the
+The function is @__cfa__virtual_cast@ and it is implemented in the
 standard library. It takes a pointer to the target type's virtual table and
 the object pointer being cast. The function is very simple, getting the
@@ -87,5 +87,5 @@
 
 For the generated code a forward decaration of the virtual works as follows.
-There is a forward declaration of \codeC{__cfa__virtual_cast} in every cfa
+There is a forward declaration of @__cfa__virtual_cast@ in every cfa
 file so it can just be used. The object argument is the expression being cast
 so that is just placed in the argument list.
@@ -110,5 +110,5 @@
 often across functions.
 
-At a very basic level this can be done with \codeC{setjmp} \& \codeC{longjmp}
+At a very basic level this can be done with @setjmp@ \& @longjmp@
 which simply move the top of the stack, discarding everything on the stack
 above a certain point. However this ignores all the clean-up code that should
@@ -118,5 +118,5 @@
 both of these problems.
 
-Libunwind, provided in \texttt{unwind.h} on most platorms, is a C library
+Libunwind, provided in @unwind.h@ on most platorms, is a C library
 that provides \CPP style stack unwinding. Its operation is divided into two
 phases. The search phase -- phase 1 -- is used to scan the stack and decide
@@ -142,5 +142,5 @@
 
 GCC will generate an LSDA and attach its personality function with the
-\texttt{-fexceptions} flag. However this only handles the cleanup attribute.
+@-fexceptions@ flag. However this only handles the cleanup attribute.
 This attribute is used on a variable and specifies a function that should be
 run when the variable goes out of scope. The function is passed a pointer to
@@ -165,26 +165,26 @@
 messages for special cases (some of which should never be used by the
 personality function) and error codes but unless otherwise noted the
-personality function should always return \codeC{_URC_CONTINUE_UNWIND}.
-
-The \codeC{version} argument is the verson of the implementation that is
+personality function should always return @_URC_CONTINUE_UNWIND@.
+
+The @version@ argument is the verson of the implementation that is
 calling the personality function. At this point it appears to always be 1 and
 it will likely stay that way until a new version of the API is updated.
 
-The \codeC{action} argument is set of flags that tell the personality
+The @action@ argument is set of flags that tell the personality
 function when it is being called and what it must do on this invocation.
 The flags are as follows:
 \begin{itemize}
-\item\codeC{_UA_SEARCH_PHASE}: This flag is set whenever the personality
+\item@_UA_SEARCH_PHASE@: This flag is set whenever the personality
 function is called during the search phase. The personality function should
 decide if unwinding will stop in this function or not. If it does then the
-personality function should return \codeC{_URC_HANDLER_FOUND}.
-\item\codeC{_UA_CLEANUP_PHASE}: This flag is set whenever the personality
+personality function should return @_URC_HANDLER_FOUND@.
+\item@_UA_CLEANUP_PHASE@: This flag is set whenever the personality
 function is called during the cleanup phase. If no other flags are set this
 means the entire frame will be unwound and all cleanup code should be run.
-\item\codeC{_UA_HANDLER_FRAME}: This flag is set during the cleanup phase
+\item@_UA_HANDLER_FRAME@: This flag is set during the cleanup phase
 on the function frame that found the handler. The personality function must
 prepare to return to normal code execution and return
-\codeC{_URC_INSTALL_CONTEXT}.
-\item\codeC{_UA_FORCE_UNWIND}: This flag is set if the personality function
+@_URC_INSTALL_CONTEXT@.
+\item@_UA_FORCE_UNWIND@: This flag is set if the personality function
 is called through a forced unwind call. Forced unwind only performs the
 cleanup phase and uses a different means to decide when to stop. See its
@@ -192,8 +192,8 @@
 \end{itemize}
 
-The \codeC{exception_class} argument is a copy of the \codeC{exception}'s
-\codeC{exception_class} field.
-
-The \codeC{exception} argument is a pointer to the user provided storage
+The @exception_class@ argument is a copy of the @exception@'s
+@exception_class@ field.
+
+The @exception@ argument is a pointer to the user provided storage
 object. It has two public fields, the exception class which is actually just
 a number that identifies the exception handling mechanism that created it and
@@ -201,5 +201,5 @@
 exception needs to 
 
-The \codeC{context} argument is a pointer to an opaque type. This is passed
+The @context@ argument is a pointer to an opaque type. This is passed
 to the many helper functions that can be called inside the personality
 function.
@@ -218,5 +218,5 @@
 functions traversing the stack new-to-old until a function finds a handler or
 the end of the stack is reached. In the latter case raise exception will
-return with \codeC{_URC_END_OF_STACK}.
+return with @_URC_END_OF_STACK@.
 
 Once a handler has been found raise exception continues onto the the cleanup
@@ -227,5 +227,5 @@
 
 If an error is encountered raise exception will return either
-\codeC{_URC_FATAL_PHASE1_ERROR} or \codeC{_URC_FATAL_PHASE2_ERROR} depending
+@_URC_FATAL_PHASE1_ERROR@ or @_URC_FATAL_PHASE2_ERROR@ depending
 on when the error occured.
 
@@ -259,13 +259,13 @@
 been unwound.
 
-Each time it is called the stop function should return \codeC{_URC_NO_REASON}
+Each time it is called the stop function should return @_URC_NO_REASON@
 or transfer control directly to other code outside of libunwind. The
 framework does not provide any assistance here.
 
 Its arguments are the same as the paired personality function.
-The actions \codeC{_UA_CLEANUP_PHASE} and \codeC{_UA_FORCE_UNWIND} are always
+The actions @_UA_CLEANUP_PHASE@ and @_UA_FORCE_UNWIND@ are always
 set when it is called. By the official standard that is all but both GCC and
 Clang add an extra action on the last call at the end of the stack:
-\codeC{_UA_END_OF_STACK}.
+@_UA_END_OF_STACK@.
 
 \section{Exception Context}
@@ -280,23 +280,23 @@
 Each stack has its own exception context. In a purely sequental program, using
 only core Cforall, there is only one stack and the context is global. However
-if the library \texttt{libcfathread} is linked then there can be multiple
+if the library @libcfathread@ is linked then there can be multiple
 stacks so they will each need their own.
 
 To handle this code always gets the exception context from the function
-\codeC{this_exception_context}. The main exception handling code is in
-\texttt{libcfa} and that library also defines the function as a weak symbol
-so it acts as a default. Meanwhile in \texttt{libcfathread} the function is
+@this_exception_context@. The main exception handling code is in
+@libcfa@ and that library also defines the function as a weak symbol
+so it acts as a default. Meanwhile in @libcfathread@ the function is
 defined as a strong symbol that replaces it when the libraries are linked
 together.
 
-The version of the function defined in \texttt{libcfa} is very simple. It
+The version of the function defined in @libcfa@ is very simple. It
 returns a pointer to a global static variable. With only one stack this
 global instance is associated with the only stack.
 
-The version of the function defined in \texttt{libcfathread} has to handle
+The version of the function defined in @libcfathread@ has to handle
 more as there are multiple stacks. The exception context is included as
 part of the per-stack data stored as part of coroutines. In the cold data
 section, stored at the base of each stack, is the exception context for that
-stack. The \codeC{this_exception_context} uses the concurrency library to get
+stack. The @this_exception_context@ uses the concurrency library to get
 the current coroutine and through it the cold data section and the exception
 context.
@@ -323,5 +323,5 @@
 to store the exception. Macros with pointer arthritic and type cast are
 used to move between the components or go from the embedded
-\codeC{_Unwind_Exception} to the entire node.
+@_Unwind_Exception@ to the entire node.
 
 All of these nodes are strung together in a linked list. One linked list per
@@ -347,5 +347,5 @@
 C which is what the \CFA compiler outputs so a work-around is used.
 
-This work around is a function called \codeC{__cfaehm_try_terminate} in the
+This work around is a function called @__cfaehm_try_terminate@ in the
 standard library. The contents of a try block and the termination handlers
 are converted into functions. These are then passed to the try terminate
@@ -385,6 +385,6 @@
 
 These nested functions and all other functions besides
-\codeC{__cfaehm_try_terminate} in \CFA use the GCC personality function and
-the \texttt{-fexceptions} flag to generate the LSDA. This allows destructors
+@__cfaehm_try_terminate@ in \CFA use the GCC personality function and
+the @-fexceptions@ flag to generate the LSDA. This allows destructors
 to be implemented with the cleanup attribute.
 
@@ -401,8 +401,8 @@
 
 The handler function does both the matching and catching. It tries each
-the condition of \codeCFA{catchResume} in order, top-to-bottom and until it
+the condition of @catchResume@ in order, top-to-bottom and until it
 finds a handler that matches. If no handler matches then the function returns
 false. Otherwise the matching handler is run, if it completes successfully
-the function returns true. Rethrows, through the \codeCFA{throwResume;}
+the function returns true. Rethrows, through the @throwResume;@
 statement, cause the function to return true.
 
@@ -438,5 +438,5 @@
 
 Cancellation also uses libunwind to do its stack traversal and unwinding,
-however it uses a different primary function \codeC{_Unwind_ForcedUnwind}.
+however it uses a different primary function @_Unwind_ForcedUnwind@.
 Details of its interface can be found in the unwind section.
 
Index: doc/theses/andrew_beach_MMath/unwinding.tex
===================================================================
--- doc/theses/andrew_beach_MMath/unwinding.tex	(revision 79e261b7c10e84cbd652f6b8e8a4ff0e7c196b4e)
+++ doc/theses/andrew_beach_MMath/unwinding.tex	(revision f7066971a8d399395addd0fa9ee744a61ac3555b)
@@ -10,7 +10,7 @@
 Even this is fairly simple if nothing needs to happen when the stack unwinds.
 Traditional C can unwind the stack by saving and restoring state (with
-\codeC{setjmp} \& \codeC{longjmp}). However many languages define actions that
+@setjmp@ \& @longjmp@). However many languages define actions that
 have to be taken when something is removed from the stack, such as running
-a variable's destructor or a \codeCFA{try} statement's \codeCFA{finally}
+a variable's destructor or a @try@ statement's @finally@
 clause. Handling this requires walking the stack going through each stack
 frame.
@@ -29,6 +29,6 @@
 
 \CFA uses two primary functions in libunwind to create most of its
-exceptional control-flow: \codeC{_Unwind_RaiseException} and
-\codeC{_Unwind_ForcedUnwind}.
+exceptional control-flow: @_Unwind_RaiseException@ and
+@_Unwind_ForcedUnwind@.
 Their operation is divided into two phases: search and clean-up. The search
 phase -- phase 1 -- is used to scan the stack but not unwinding it. The
@@ -44,25 +44,25 @@
 A personality function performs three tasks, although not all have to be
 present. The tasks performed are decided by the actions provided.
-\codeC{_Unwind_Action} is a bitmask of possible actions and an argument of
+@_Unwind_Action@ is a bitmask of possible actions and an argument of
 this type is passed into the personality function.
 \begin{itemize}
-\item\codeC{_UA_SEARCH_PHASE} is passed in search phase and tells the
+\item@_UA_SEARCH_PHASE@ is passed in search phase and tells the
 personality function to check for handlers. If there is a handler in this
 stack frame, as defined by the language, the personality function should
-return \codeC{_URC_HANDLER_FOUND}. Otherwise it should return
-\codeC{_URC_CONTINUE_UNWIND}.
-\item\codeC{_UA_CLEANUP_PHASE} is passed in during the clean-up phase and
+return @_URC_HANDLER_FOUND@. Otherwise it should return
+@_URC_CONTINUE_UNWIND@.
+\item@_UA_CLEANUP_PHASE@ is passed in during the clean-up phase and
 means part or all of the stack frame is removed. The personality function
 should do whatever clean-up the language defines
 (such as running destructors/finalizers) and then generally returns
-\codeC{_URC_CONTINUE_UNWIND}.
-\item\codeC{_UA_HANDLER_FRAME} means the personality function must install
+@_URC_CONTINUE_UNWIND@.
+\item@_UA_HANDLER_FRAME@ means the personality function must install
 a handler. It is also passed in during the clean-up phase and is in addition
 to the clean-up action. libunwind provides several helpers for the personality
 function here. Once it is done, the personality function must return
-\codeC{_URC_INSTALL_CONTEXT}.
+@_URC_INSTALL_CONTEXT@.
 \end{itemize}
 The personality function is given a number of other arguments. Some are for
-compatability and there is the \codeC{struct _Unwind_Context} pointer which
+compatability and there is the @struct _Unwind_Context@ pointer which
 passed to many helpers to get information about the current stack frame.
 
@@ -72,5 +72,5 @@
 raise-exception but with some extras.
 The first it passes in an extra action to the personality function on each
-stack frame, \codeC{_UA_FORCE_UNWIND}, which means a handler cannot be
+stack frame, @_UA_FORCE_UNWIND@, which means a handler cannot be
 installed.
 
@@ -83,8 +83,8 @@
 stack frames have been removed. By the standard API this is marked by setting
 the stack pointer inside the context passed to the stop function. However both
-GCC and Clang add an extra action for this case \codeC{_UA_END_OF_STACK}.
+GCC and Clang add an extra action for this case @_UA_END_OF_STACK@.
 
 Each time function the stop function is called it can do one or two things.
-When it is not the end of the stack it can return \codeC{_URC_NO_REASON} to
+When it is not the end of the stack it can return @_URC_NO_REASON@ to
 continue unwinding.
 % Is there a reason that NO_REASON is used instead of CONTINUE_UNWIND?
@@ -113,5 +113,5 @@
 
 The stop function is very simple. It checks the end of stack flag to see if
-it is finished unwinding. If so, it calls \codeC{exit} to end the process,
+it is finished unwinding. If so, it calls @exit@ to end the process,
 otherwise it returns with no-reason to continue unwinding.
 % Yeah, this is going to have to change.
@@ -128,18 +128,18 @@
 location of the instruction pointer and stack layout, which varies with
 compiler and optimization levels. So for frames where there are only
-destructors, GCC's attribute cleanup with the \texttt{-fexception} flag is
+destructors, GCC's attribute cleanup with the @-fexception@ flag is
 sufficient to handle unwinding.
 
 The only functions that require more than that are those that contain
-\codeCFA{try} statements. A \codeCFA{try} statement has a \codeCFA{try}
-clause, some number of \codeCFA{catch} clauses and \codeCFA{catchResume}
-clauses and may have a \codeCFA{finally} clause. Of these only \codeCFA{try}
-statements with \codeCFA{catch} clauses need to be transformed and only they
-and the \codeCFA{try} clause are involved.
+@try@ statements. A @try@ statement has a @try@
+clause, some number of @catch@ clauses and @catchResume@
+clauses and may have a @finally@ clause. Of these only @try@
+statements with @catch@ clauses need to be transformed and only they
+and the @try@ clause are involved.
 
-The \codeCFA{try} statement is converted into a series of closures which can
+The @try@ statement is converted into a series of closures which can
 access other parts of the function according to scoping rules but can be
-passed around. The \codeCFA{try} clause is converted into the try functions,
-almost entirely unchanged. The \codeCFA{catch} clauses are converted into two
+passed around. The @try@ clause is converted into the try functions,
+almost entirely unchanged. The @catch@ clauses are converted into two
 functions; the match function and the catch function.
 
@@ -153,5 +153,5 @@
 runs the handler's body.
 
-These three functions are passed to \codeC{try_terminate}. This is an
+These three functions are passed to @try_terminate@. This is an
 % Maybe I shouldn't quote that, it isn't its actual name.
 internal hand-written function that has its own personality function and
@@ -167,7 +167,7 @@
 handler was found in this frame. If it was then the personality function
 installs the handler, which is setting the instruction pointer in
-\codeC{try_terminate} to an otherwise unused section that calls the catch
+@try_terminate@ to an otherwise unused section that calls the catch
 function, passing it the current exception and handler index.
-\codeC{try_terminate} returns as soon as the catch function returns.
+@try_terminate@ returns as soon as the catch function returns.
 
 At this point control has returned to normal control flow.
Index: doc/theses/andrew_beach_MMath/uw-ethesis-frontpgs.tex
===================================================================
--- doc/theses/andrew_beach_MMath/uw-ethesis-frontpgs.tex	(revision f7066971a8d399395addd0fa9ee744a61ac3555b)
+++ doc/theses/andrew_beach_MMath/uw-ethesis-frontpgs.tex	(revision f7066971a8d399395addd0fa9ee744a61ac3555b)
@@ -0,0 +1,173 @@
+% T I T L E   P A G E
+% -------------------
+% Last updated October 23, 2020, by Stephen Carr, IST-Client Services
+% The title page is counted as page `i' but we need to suppress the
+% page number. Also, we don't want any headers or footers.
+\pagestyle{empty}
+\pagenumbering{roman}
+
+% The contents of the title page are specified in the "titlepage"
+% environment.
+\begin{titlepage}
+        \begin{center}
+        \vspace*{1.0cm}
+
+        \Huge
+        {\bf Exception Handling in \CFA}
+
+        \vspace*{1.0cm}
+
+        \normalsize
+        by \\
+
+        \vspace*{1.0cm}
+
+        \Large
+        Andrew James Beach \\
+
+        \vspace*{3.0cm}
+
+        \normalsize
+        A thesis \\
+        presented to the University of Waterloo \\ 
+        in fulfillment of the \\
+        thesis requirement for the degree of \\
+        Master of Mathematics \\
+        in \\
+        Computer Science \\
+
+        \vspace*{2.0cm}
+
+        Waterloo, Ontario, Canada, \the\year \\
+
+        \vspace*{1.0cm}
+
+        \copyright\ Andrew James Beach \the\year \\
+        \end{center}
+\end{titlepage}
+
+% The rest of the front pages should contain no headers and be numbered using Roman numerals starting with `ii'
+\pagestyle{plain}
+\setcounter{page}{2}
+
+\cleardoublepage % Ends the current page and causes all figures and tables that have so far appeared in the input to be printed.
+% In a two-sided printing style, it also makes the next page a right-hand (odd-numbered) page, producing a blank page if necessary.
+
+\begin{comment} 
+% E X A M I N I N G   C O M M I T T E E (Required for Ph.D. theses only)
+% Remove or comment out the lines below to remove this page
+\begin{center}\textbf{Examining Committee Membership}\end{center}
+  \noindent
+The following served on the Examining Committee for this thesis. The decision of the Examining Committee is by majority vote.
+  \bigskip
+  
+  \noindent
+\begin{tabbing}
+Internal-External Member: \=  \kill % using longest text to define tab length
+External Examiner: \>  Bruce Bruce \\ 
+\> Professor, Dept. of Philosophy of Zoology, University of Wallamaloo \\
+\end{tabbing} 
+  \bigskip
+  
+  \noindent
+\begin{tabbing}
+Internal-External Member: \=  \kill % using longest text to define tab length
+Supervisor(s): \> Ann Elk \\
+\> Professor, Dept. of Zoology, University of Waterloo \\
+\> Andrea Anaconda \\
+\> Professor Emeritus, Dept. of Zoology, University of Waterloo \\
+\end{tabbing}
+  \bigskip
+  
+  \noindent
+  \begin{tabbing}
+Internal-External Member: \=  \kill % using longest text to define tab length
+Internal Member: \> Pamela Python \\
+\> Professor, Dept. of Zoology, University of Waterloo \\
+\end{tabbing}
+  \bigskip
+  
+  \noindent
+\begin{tabbing}
+Internal-External Member: \=  \kill % using longest text to define tab length
+Internal-External Member: \> Meta Meta \\
+\> Professor, Dept. of Philosophy, University of Waterloo \\
+\end{tabbing}
+  \bigskip
+  
+  \noindent
+\begin{tabbing}
+Internal-External Member: \=  \kill % using longest text to define tab length
+Other Member(s): \> Leeping Fang \\
+\> Professor, Dept. of Fine Art, University of Waterloo \\
+\end{tabbing}
+
+\cleardoublepage
+\end{comment}
+
+% D E C L A R A T I O N   P A G E
+% -------------------------------
+  % The following is a sample Delaration Page as provided by the GSO
+  % December 13th, 2006.  It is designed for an electronic thesis.
+ \begin{center}\textbf{Author's Declaration}\end{center}
+  
+ \noindent
+I hereby declare that I am the sole author of this thesis. This is a true copy of the thesis, including any required final revisions, as accepted by my examiners.
+
+  \bigskip
+  
+  \noindent
+I understand that my thesis may be made electronically available to the public.
+
+\cleardoublepage
+
+% A B S T R A C T
+% ---------------
+
+\begin{center}\textbf{Abstract}\end{center}
+
+This is the abstract.
+
+\cleardoublepage
+
+% A C K N O W L E D G E M E N T S
+% -------------------------------
+
+\begin{center}\textbf{Acknowledgements}\end{center}
+
+I would like to thank all the little people who made this thesis possible.
+\cleardoublepage
+
+\begin{comment}
+% D E D I C A T I O N
+% -------------------
+
+\begin{center}\textbf{Dedication}\end{center}
+
+This is dedicated to the one I love.
+\cleardoublepage
+\end{comment}
+
+% T A B L E   O F   C O N T E N T S
+% ---------------------------------
+\renewcommand\contentsname{Table of Contents}
+\tableofcontents
+\cleardoublepage
+\phantomsection    % allows hyperref to link to the correct page
+
+% L I S T   O F   F I G U R E S
+% -----------------------------
+\addcontentsline{toc}{chapter}{List of Figures}
+\listoffigures
+\cleardoublepage
+\phantomsection		% allows hyperref to link to the correct page
+
+% 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
+
+% Change page numbering back to Arabic numerals
+\pagenumbering{arabic}
Index: doc/theses/andrew_beach_MMath/uw-ethesis.bib
===================================================================
--- doc/theses/andrew_beach_MMath/uw-ethesis.bib	(revision f7066971a8d399395addd0fa9ee744a61ac3555b)
+++ doc/theses/andrew_beach_MMath/uw-ethesis.bib	(revision f7066971a8d399395addd0fa9ee744a61ac3555b)
@@ -0,0 +1,28 @@
+% Bibliography of key references for "LaTeX for Thesis and Large Documents"
+% For use with BibTeX
+
+@book{goossens.book,
+	author =	"Michel Goossens and Frank Mittelbach and 
+			 Alexander Samarin",
+	title =		"The \LaTeX\ Companion",
+	year = 		"1994",
+	publisher =	"Addison-Wesley",
+	address = 	"Reading, Massachusetts"
+}
+
+@book{knuth.book,
+        author =        "Donald Knuth",
+        title =         "The \TeX book",
+        year =          "1986",
+        publisher =     "Addison-Wesley",
+        address =       "Reading, Massachusetts"
+}
+
+@book{lamport.book,
+	author =        "Leslie Lamport",
+	title =         "\LaTeX\ --- A Document Preparation System",
+        edition =       "Second",
+	year = 		"1994",
+	publisher = 	"Addison-Wesley",
+	address =       "Reading, Massachusetts"
+}
Index: doc/theses/andrew_beach_MMath/uw-thesis.tex
===================================================================
--- doc/theses/andrew_beach_MMath/uw-thesis.tex	(revision f7066971a8d399395addd0fa9ee744a61ac3555b)
+++ doc/theses/andrew_beach_MMath/uw-thesis.tex	(revision f7066971a8d399395addd0fa9ee744a61ac3555b)
@@ -0,0 +1,240 @@
+%======================================================================
+% University of Waterloo Thesis Template for LaTeX 
+% Last Updated November, 2020 
+% by Stephen Carr, IST Client Services, 
+% University of Waterloo, 200 University Ave. W., Waterloo, Ontario, Canada
+% FOR ASSISTANCE, please send mail to request@uwaterloo.ca
+
+% DISCLAIMER
+% To the best of our knowledge, this template satisfies the current uWaterloo thesis requirements.
+% However, it is your responsibility to assure that you have met all requirements of the University and your particular department.
+
+% Many thanks for the feedback from many graduates who assisted the development of this template.
+% Also note that there are explanatory comments and tips throughout this template.
+%======================================================================
+% Some important notes on using this template and making it your own...
+
+% The University of Waterloo has required electronic thesis submission since October 2006. 
+% See the uWaterloo thesis regulations at
+% https://uwaterloo.ca/graduate-studies/thesis.
+% This thesis template is geared towards generating a PDF version optimized for viewing on an electronic display, including hyperlinks within the PDF.
+
+% DON'T FORGET TO ADD YOUR OWN NAME AND TITLE in the "hyperref" package configuration below. 
+% THIS INFORMATION GETS EMBEDDED IN THE PDF FINAL PDF DOCUMENT.
+% You can view the information if you view properties of the PDF document.
+
+% Many faculties/departments also require one or more printed copies. 
+% This template attempts to satisfy both types of output. 
+% See additional notes below.
+% It is based on the standard "book" document class which provides all necessary sectioning structures and allows multi-part theses.
+
+% If you are using this template in Overleaf (cloud-based collaboration service), then it is automatically processed and previewed for you as you edit.
+
+% For people who prefer to install their own LaTeX distributions on their own computers, and process the source files manually, the following notes provide the sequence of tasks:
+ 
+% E.g. to process a thesis called "mythesis.tex" based on this template, run:
+
+% pdflatex mythesis	-- first pass of the pdflatex processor
+% bibtex mythesis	-- generates bibliography from .bib data file(s)
+% makeindex         -- should be run only if an index is used 
+% pdflatex mythesis	-- fixes numbering in cross-references, bibliographic references, glossaries, index, etc.
+% pdflatex mythesis	-- it takes a couple of passes to completely process all cross-references
+
+% If you use the recommended LaTeX editor, Texmaker, you would open the mythesis.tex file, then click the PDFLaTeX button. Then run BibTeX (under the Tools menu).
+% Then click the PDFLaTeX button two more times. 
+% If you have an index as well,you'll need to run MakeIndex from the Tools menu as well, before running pdflatex
+% the last two times.
+
+% N.B. The "pdftex" program allows graphics in the following formats to be included with the "\includegraphics" command: PNG, PDF, JPEG, TIFF
+% Tip: Generate your figures and photos in the size you want them to appear in your thesis, rather than scaling them with \includegraphics options.
+% Tip: Any drawings you do should be in scalable vector graphic formats: SVG, PNG, WMF, EPS and then converted to PNG or PDF, so they are scalable in the final PDF as well.
+% Tip: Photographs should be cropped and compressed so as not to be too large.
+
+% To create a PDF output that is optimized for double-sided printing: 
+% 1) comment-out the \documentclass statement in the preamble below, and un-comment the second \documentclass line.
+% 2) change the value assigned below to the boolean variable "PrintVersion" from " false" to "true".
+
+%======================================================================
+%   D O C U M E N T   P R E A M B L E
+% Specify the document class, default style attributes, and page dimensions, etc.
+% For hyperlinked PDF, suitable for viewing on a computer, use this:
+\documentclass[letterpaper,12pt,titlepage,oneside,final]{book}
+
+% For PDF, suitable for double-sided printing, change the PrintVersion variable below to "true" and use this \documentclass line instead of the one above:
+%\documentclass[letterpaper,12pt,titlepage,openright,twoside,final]{book}
+
+% Some LaTeX commands I define for my own nomenclature.
+% If you have to, it's easier to make changes to nomenclature once here than in a million places throughout your thesis!
+\newcommand{\package}[1]{\textbf{#1}} % package names in bold text
+\newcommand{\cmmd}[1]{\textbackslash\texttt{#1}} % command name in tt font 
+\newcommand{\href}[1]{#1} % does nothing, but defines the command so the print-optimized version will ignore \href tags (redefined by hyperref pkg).
+%\newcommand{\texorpdfstring}[2]{#1} % does nothing, but defines the command
+% Anything defined here may be redefined by packages added below...
+
+% This package allows if-then-else control structures.
+\usepackage{ifthen}
+\newboolean{PrintVersion}
+\setboolean{PrintVersion}{false}
+% CHANGE THIS VALUE TO "true" as necessary, to improve printed results for hard copies by overriding some options of the hyperref package, called below.
+
+%\usepackage{nomencl} % For a nomenclature (optional; available from ctan.org)
+\usepackage{amsmath,amssymb,amstext} % Lots of math symbols and environments
+\usepackage[pdftex]{graphicx} % For including graphics N.B. pdftex graphics driver 
+
+% Hyperlinks make it very easy to navigate an electronic document.
+% In addition, this is where you should specify the thesis title and author as they appear in the properties of the PDF document.
+% Use the "hyperref" package
+% N.B. HYPERREF MUST BE THE LAST PACKAGE LOADED; ADD ADDITIONAL PKGS ABOVE
+\usepackage[pdftex,pagebackref=true]{hyperref} % with basic options
+%\usepackage[pdftex,pagebackref=true]{hyperref}
+		% N.B. pagebackref=true provides links back from the References to the body text. This can cause trouble for printing.
+\hypersetup{
+    plainpages=false,       % needed if Roman numbers in frontpages
+    unicode=false,          % non-Latin characters in Acrobat’s bookmarks
+    pdftoolbar=true,        % show Acrobat’s toolbar?
+    pdfmenubar=true,        % show Acrobat’s menu?
+    pdffitwindow=false,     % window fit to page when opened
+    pdfstartview={FitH},    % fits the width of the page to the window
+%    pdftitle={uWaterloo\ LaTeX\ Thesis\ Template},    % title: CHANGE THIS TEXT!
+%    pdfauthor={Author},    % author: CHANGE THIS TEXT! and uncomment this line
+%    pdfsubject={Subject},  % subject: CHANGE THIS TEXT! and uncomment this line
+%    pdfkeywords={keyword1} {key2} {key3}, % list of keywords, and uncomment this line if desired
+    pdfnewwindow=true,      % links in new window
+    colorlinks=true,        % false: boxed links; true: colored links
+    linkcolor=blue,         % color of internal links
+    citecolor=green,        % color of links to bibliography
+    filecolor=magenta,      % color of file links
+    urlcolor=cyan           % color of external links
+}
+\ifthenelse{\boolean{PrintVersion}}{   % for improved print quality, change some hyperref options
+\hypersetup{	% override some previously defined hyperref options
+%    colorlinks,%
+    citecolor=black,%
+    filecolor=black,%
+    linkcolor=black,%
+    urlcolor=black}
+}{} % end of ifthenelse (no else)
+
+\usepackage[automake,toc,abbreviations]{glossaries-extra} % Exception to the rule of hyperref being the last add-on package
+% If glossaries-extra is not in your LaTeX distribution, get it from CTAN (http://ctan.org/pkg/glossaries-extra),
+% although it's supposed to be in both the TeX Live and MikTeX distributions. There are also documentation and 
+% installation instructions there.
+
+% Setting up the page margins...
+\setlength{\textheight}{9in}\setlength{\topmargin}{-0.45in}\setlength{\headsep}{0.25in}
+% uWaterloo thesis requirements specify a minimum of 1 inch (72pt) margin at the
+% top, bottom, and outside page edges and a 1.125 in. (81pt) gutter margin (on binding side). 
+% While this is not an issue for electronic viewing, a PDF may be printed, and so we have the same page layout for both printed and electronic versions, we leave the gutter margin in.
+% Set margins to minimum permitted by uWaterloo thesis regulations:
+\setlength{\marginparwidth}{0pt} % width of margin notes
+% N.B. If margin notes are used, you must adjust \textwidth, \marginparwidth
+% and \marginparsep so that the space left between the margin notes and page
+% edge is less than 15 mm (0.6 in.)
+\setlength{\marginparsep}{0pt} % width of space between body text and margin notes
+\setlength{\evensidemargin}{0.125in} % Adds 1/8 in. to binding side of all
+% even-numbered pages when the "twoside" printing option is selected
+\setlength{\oddsidemargin}{0.125in} % Adds 1/8 in. to the left of all pages when "oneside" printing is selected, and to the left of all odd-numbered pages when "twoside" printing is selected
+\setlength{\textwidth}{6.375in} % assuming US letter paper (8.5 in. x 11 in.) and side margins as above
+\raggedbottom
+
+% The following statement specifies the amount of space between paragraphs. Other reasonable specifications are \bigskipamount and \smallskipamount.
+\setlength{\parskip}{\medskipamount}
+
+% The following statement controls the line spacing.  
+% The default spacing corresponds to good typographic conventions and only slight changes (e.g., perhaps "1.2"), if any, should be made.
+\renewcommand{\baselinestretch}{1} % this is the default line space setting
+
+% By default, each chapter will start on a recto (right-hand side) page.
+% We also force each section of the front pages to start on a recto page by inserting \cleardoublepage commands.
+% In many cases, this will require that the verso (left-hand) page be blank, and while it should be counted, a page number should not be printed.
+% The following statements ensure a page number is not printed on an otherwise blank verso page.
+\let\origdoublepage\cleardoublepage
+\newcommand{\clearemptydoublepage}{%
+  \clearpage{\pagestyle{empty}\origdoublepage}}
+\let\cleardoublepage\clearemptydoublepage
+
+% Define Glossary terms (This is properly done here, in the preamble and could also be \input{} from a separate file...)
+\input{glossaries}
+\makeglossaries
+
+\usepackage{comment}
+% cfa macros used in the document
+%\usepackage{cfalab}
+\input{common}
+\CFAStyle						% CFA code-style for all languages
+\lstset{basicstyle=\linespread{0.9}\tt}
+
+%======================================================================
+%   L O G I C A L    D O C U M E N T
+% The logical document contains the main content of your thesis.
+% Being a large document, it is a good idea to divide your thesis into several files, each one containing one chapter or other significant chunk of content, so you can easily shuffle things around later if desired.
+%======================================================================
+\begin{document}
+
+%----------------------------------------------------------------------
+% FRONT MATERIAL
+% title page,declaration, borrowers' page, abstract, acknowledgements,
+% dedication, table of contents, list of tables, list of figures, nomenclature, etc.
+%----------------------------------------------------------------------
+\input{uw-ethesis-frontpgs} 
+
+%----------------------------------------------------------------------
+% MAIN BODY
+% We suggest using a separate file for each chapter of your thesis.
+% Start each chapter file with the \chapter command.
+% Only use \documentclass or \begin{document} and \end{document} commands in this master document.
+% Tip: Putting each sentence on a new line is a way to simplify later editing.
+%----------------------------------------------------------------------
+\input{existing}
+\input{features}
+\input{unwinding}
+\input{future}
+
+%----------------------------------------------------------------------
+% END MATERIAL
+% Bibliography, Appendices, Index, etc.
+%----------------------------------------------------------------------
+
+% Bibliography
+
+% The following statement selects the style to use for references.  
+% It controls the sort order of the entries in the bibliography and also the formatting for the in-text labels.
+\bibliographystyle{plain}
+% This specifies the location of the file containing the bibliographic information.  
+% It assumes you're using BibTeX to manage your references (if not, why not?).
+\cleardoublepage % This is needed if the "book" document class is used, to place the anchor in the correct page, because the bibliography will start on its own page.
+% Use \clearpage instead if the document class uses the "oneside" argument
+\phantomsection  % With hyperref package, enables hyperlinking from the table of contents to bibliography             
+% The following statement causes the title "References" to be used for the bibliography section:
+\renewcommand*{\bibname}{References}
+
+% Add the References to the Table of Contents
+\addcontentsline{toc}{chapter}{\textbf{References}}
+
+\bibliography{uw-ethesis,pl}
+% Tip: You can create multiple .bib files to organize your references. 
+% Just list them all in the \bibliogaphy command, separated by commas (no spaces).
+
+% The following statement causes the specified references to be added to the bibliography even if they were not cited in the text. 
+% The asterisk is a wildcard that causes all entries in the bibliographic database to be included (optional).
+% \nocite{*}
+%----------------------------------------------------------------------
+
+% Appendices
+
+% The \appendix statement indicates the beginning of the appendices.
+\appendix
+% Add an un-numbered title page before the appendices and a line in the Table of Contents
+% \chapter*{APPENDICES}
+% \addcontentsline{toc}{chapter}{APPENDICES}
+% Appendices are just more chapters, with different labeling (letters instead of numbers).
+% \input{appendix-matlab_plots.tex}
+
+% GLOSSARIES (Lists of definitions, abbreviations, symbols, etc. provided by the glossaries-extra package)
+% -----------------------------
+\printglossaries
+\cleardoublepage
+\phantomsection		% allows hyperref to link to the correct page
+
+%----------------------------------------------------------------------
+\end{document} % end of logical document
