fixed some bitwise arithmatic