Made some fixes to image loading