Grill 618 - Make Rewrite pluggable

Initial review draft. Adding Tests for new code are still pending. Am working on them Existing tests are passing.