LZW compression, ternary tries bugs fixes