Added reconnect logic.