Fix starting problems with threads