Changing the file entry to return a file for a given uri, and using file_delete() instead of custom implementation.