Added functions for bit-packing