remove many function calls; simplify xor; whitespace