Fixed the encode/decode methods.