added performance optimizations for ALL_OF and FIRST/ANY_OF context switches