Replaced file locking code