Switch to thread local storage from cutils.
Merge pull request #820 from brendandahl/thread-local

Switch to thread local storage from cutils.