Thread changes

Thread changes for better use of resources