Change the code for mapThreadTimeSeries so that it is faster