Make Rewrite layer pluggable

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