multithreading related bug-fixies