States -> Phases (more obviously), some number of necessary fixes.

Signed-off-by: Stanislav Demyanovich <stan@angrybubo.com>