Thread pool cleanup - and other fixes