ad-hoc implementation for huffman encoding/decoding types.