Fixed bitshift operations not working correctly