Minor fixes

see: http://stackoverflow.com/questions/12424838/threadlocal-remove