Fixed bad bit shift and sign extension errors