Refactor code for the ImageLoader.