Restructured TS map computation

As close to final as it could get today.
Split this computation into separate statements using temp variable.

I generally prefer this because:
* If there's an exception it's easier to understand what expression is responsible.
* I find it more readable
* it doesn't cost anything in terms of efficiency because Python generates temp variables internally anyways.