Redesigned serialization and fixed the diamond inheritance problem