Fix locking of files