Fixed bug concerning wrong number of threads