[WIP] Refactored for new ODM query & query builder

This is theoretically finished, in as much as all the tests pass. But will try it out in battle later.