Refactor the AST hierarchy