Fixed some thread stuff