Improve file fetching reliability and error handling