Added support for serialization and deserialization.