Fix #229 - Refactor message structure

This is a huge change. Needs to be tested.