Small refactoring of PlanContext and surrounding classes