Refactoring to support Decorators

This was a long haul. I split query operataions from editing operations
so I can decorate editing operatinos and queries seperately.
More refactoring.