Added logging mutex (active when logging level == DEBUG), fixed messages deadlock