Haffman simple implementation. May have some bugs