Make Rewrite layer pluggable

Initial review draft. Adding Tests for new code are still pending. Am working on them Existing tests are passing.
What is the purpose of this method? It creates an inner class with stub code?
This seems to be present in all subclasses of QueryCommand
Also, for each command why do we have Command abstract class and Command Impl class? Is it likely that there will be multiple implementations of each command? If no, then this hierarchy seems unnecessary.