Refactor: extract plan_builder.