Implemented encode/decode functionality.