Code and unit tests present for new style query. Breaking changes ahead (in a separate commit)