Fix serialization: deteriministic ordering and deserialize NoneType correctly.