Serialize and deserialize the client