Refactored xor operations to be more python-like