Refactored bitwise ops + various other stuff.