Revert "Remove lock from writes"

This reverts commit 4e4aba6d59b061fbd2d65ad51bd50f2201d0a53c.