Improved (de)serialization support

Reuses (de)serialization code to make things a little nicer