fix errors and allow reconnect