fix reconnect after timeout logic and other small fixs