Slightly improved error handling when sending mesages