Fix integer overflow issue in bits allocated