Added some thread tracking and logging