Rewrite many AST and grammar rules (#38)