Huffman fixes

Bugfix and performance enhancement.