remove casts from serialization code