Updated handling of connection errors.