Refactor query hierarchy.
Refactor expression codegen.
Update query handlers.