Fixed broken serialization logic