Changed reconnection algorithm