Elegant state machine for Swift.