Minor code beautifications.
Added Phases object to simplify transitions.