Bugfixes to handle correctly file deletion.