Correct serialization and simple optimization