Added reconnection logic. Nicer quit.