Fix MAGN-2317

@lukechurch

This submission takes use of the following commit:
https://github.com/DynamoDS/Dynamo/commit/a567190311f09f4a8c7acab087d27a94783471d6

The submission make some changes to the original code to fix several errors because some code has changed ever since.

This submission fixes magn-2317.
In a multi-threading environment, singleton is better. But I do realize a problem here. Usually a singleton instance will not be assigned to a new variable. Anywhere the singleton instance is required, we call the function directly. I will remove the member variable.