change the way main image is preloaded, renamed some variables