Changed to use the new threadlocal