General rewrite