Documented the AST transformation, and cleaned up some code