Fix statistics

This removes the dirty hack of unlocking the global context while in `nn_global_init`. This time it's tested by integration tests.

The patch is submitted under MIT License