Factor out the ThreadLocal declarations into a macro