Finish simplifying the AST

In order to make it easier to format the output, I needed to restructure
the generated expressions to make it easier to recursively visit the
nodes.