Further optimizations. Shaves off ~43% computation time.