Performance Optimization: Optimized traverse, explodeMine, CalcValues functions