changing dodgy arithmetic on booleans to logical_and, logical_not etc.