Refactored [de]serialize methods to seperate methods for client and server.