Refactor QueryPlanProducer
Re-enable broken tests
WIP