Improvements to (de)serialization