fix number of leaks and other minor issues (by coverity scan)
add sanity check to huffcdic indices count