Optimize boolean operations