reworked message classes/structs to ensure memory is cleaned up in all cases