Message marshalling/unmarshalling refactoring.