fix bug with incomplete rewrite, undo changes