Change loop ordering for ~~8x speedup