Rewriting fixes