[#1982] Limit the usage of ThreadLocal.get() for performance reasons