Moved some serialization functions around and added some message fields