Added error handling for fileref deletion