remove use of threadlocal