Refactored serialization. Added client support.