First step to get PSTH to run faster by using a thread pool

Minor bug fixed.