added missing xor() definition, and refactored tilePlane code