Make thread locals easier to manage

Just some minor tidy up around thread locals.