Huffman code refactoring