revised locking in Capabilities/CapsHandlers.cs