Use auto mutex

These commits makes code simple by using AutoMutexLock that is recently added.