Improve the API for sending messages