Fix truncation of MessageData and calculate packet length correctly.