changes saved from attempt at refactoring document locking