thread bugfixes