Refactor planner.