Bugfixes in connection handling.