Moved mutex initialization inside ENABLE_THREAD_SAFETY guards.