Optimized the image loading

Optimized the image loading so that it wouldn't load all the images
every time. It's much faster now.