Refactor QueryTemplate into its own (internal) module.  Adopt Object-based "q" API.