Fix bit overflow handling