Re-submission of CachedThreadScheduler

Merged in the latest from the master branch and refactored some internals in CachedThreadScheduler to better match the latest ```Scheduler``` changes. Aimed at solving #1140