Various connection fixes
Merge pull request #534 from godarklight/connection-fixes

Various connection fixes