Remove unneded boolean operations