Added some error handling if the connection dies.