Fix bugs caused by moving fetch_image out of main