Rewrite

Begins app rewrite.
Inner functions should be listed at the top of the outer function.