minor bugfix / improvements. Multithreading fixes