Fixed bug in thread trees