Adds serialization and deserialization of segments