Serialization code.