Rewriting improvements