Updated serialization code.