Misc fixes to messaging code