Standardize locked_files usage and fix to allow changes in files between unlock and lock