Changed error handling again, as the error is not always set in errno, it