made rewriting more efficient by adding script, and removing arguments from rewrite scripts