bugfix: weird side effects when used with pthreads