Fix bit juggling issues