Changed smMain to use a coroutine instead of a state machine.