Fix thread-local storage key when several docs are used