Added optional pthread thread local storage support