Reverted the use of ThreadLocal as this causes memory leaks in webapps.

For details on how it happens, see
http://people.apache.org/~markt/presentations/2010-11-04-Memory-Leaks-60mins.pdf