Fixed a few issues with handling broken connections