Implemented locking for mutating peer metadata (to facilitate multithreading).