Changed the NOT function from an xor with uint_max to an inversion (~)