Fixed possible misassignment of images
Added comments