Decoder/encoder implementation.