Fix mutex lock
Fix warnings on clang
Fix build on clang