Refactor a lot of logic up to the BaseMsgHdr and BaseCmsgHdr classes.