Huffman encoding remade + small fixes