optimizations for BFS/values