Move all encoding/decoding to message module.