Refactoring of how PlannerQuery is constructed