Replace map-based cache with array; 10x speedup!