Tidying up some messaging code.