Refactor HuffmanTableEncoder