added xor + few fixes