Better implementation of AST printer.