Fixed Bug for multiple images from one XML

Also improved computation speed.