Feature/phasegroups

Internal refactoring to improve how we track the success (or otherwise) of phases.