Added code to try and stop too many threads being created