Fix ThreadLocal memory leak