Fix entity serialization