not using thread local cause a StackOverflow exception (have to investigate)