Fixed bug where max number fo threads could be less than the number of cores detected