Added main "happy path" state machine logic.