bug fixes in reconnect logic