Implemented delayed file delete

Added code to delay file deletion when file is locked.