fixed bitwise and, or, xor and minor optimizations