Added fixes for sloppy loading of images in phonegap using promises and repeated function calls