Hoisted some calculations and removed redundancy.

I think the * is still creating a new array though which has to be GC'd.
Nothing important
Merge changes