fixed a but in threathandler which caused a corruption of the internal
linkedlists