Add safeguard against ThreadLocal being set