Fix data race and deadlock in Debug code

Calling 'Info' was leading to deadlocks since the 'what' passed to
the macro contained a call which attempted to take a lock. This was
leading to a lock inversion compared to other calls to 'Info'. The
fix was to use an atomic to safely check the debug level and then
only lock when outputing the message.
The Instance method also had a data race for setting up the global
pointer. It was possible for two threads to simultaneously change
the global pointer and get different results returned. This was
fixed with the use of an atomic pointer and 'compare exchange strong'
semantics.