Use threadsafe singleton code.
Merge pull request #2 from Rolken/master

Use threadsafe singleton code