Drop use of ThreadLocal, which causes class loader leaks.

This reverts the main part of 0c6089be9dad12bd5902b0a54591319885cafd47.
Merge branch 'pulls/98'