QueryPlan refactorings