Added more detailed logging and fixed reconnect logic for segment
client.