Clean up serialization code