cleaned up main ast rewriter