removes additional global missed in last commit ($used_threads) and now passes the variable by reference to the areas where needed.