Cleaner thread pool termination
Missing imports and minor fixes