I think thread-local storage would be a good idea. At the least, ti doesn't seem worse?