Revert "Remove locks"

This reverts commit e90db4c3b480d5f0d507d44497dd9d41040349db.