Fixed bugs in bit-shifting