Restructured TS map computation

As close to final as it could get today.
OK, there's a fork ... Axel, please try adding this one instead to `extern`:
https://github.com/redodo/lunch