made internal data structures thread safe