Improved AST conversion and pretty printing