Speed up hasAnyof/hasAllOf checks
code cleanup
fix comment