Bugfixes for disconnection