Thread local configuration

If we saved the current value here it would be possible to safely nest calls.

(See the ruby documentation for a [similar idiom](http://www.ruby-doc.org/core-2.1.2/Thread.html#method-i-5B-5D).)