adds file locking, fixes `remove` method