Added locking for containment operations.