Move singleton debug code into diagnostic. Add docs