Fixed connection errors yet again, hopefully in a more robust way this time