Fix thread local error

Closes #116