Improvements to adaptive thread number