Bug fix for MemoryPool::lock

Usage of MutexLockGuard for all operations with MemoryPool::lock