Bugfix for socket error handling