Fixed segmentation fault on reconnect