Restructured TS map computation

As close to final as it could get today.
Add newline at end of file.