Fixed issue where disconnecting and reconnecting caused a crash