Koe/state machine

NATc refactoring to use state machine control