Change some logical ands to bitwise ands and add