improved multithread support