Most of state machine done