Improved download code to make sure file closed and flushed by time future from fetch is Done