Refactoring of message encoding/decoding. All taken care of by code-generator now. Makes the code a lot simplier to follow.