Fixed reconnect of client (it threw exception and did not return 0), and prevented looping of state updates.