Add cksems to util.h
Convert the thread locking to use cksems
Pass strict sizes to decompress length, rounding up only the amount we're allocating to not confuse decompression libraries