Added XOR and fixed bug

Sometimes expressions were erased if they were malformed and a button
was clicked. This is fixed.