added the thread_local flag for situations where gcc versions < 4.8. Has to be removed when a 4.8 becomes stable.