Refactored codec/encoder/decoder.