cleaning and fixing thread scheduler