Improved the API for message handling and updated plugin_channel to use it.