Improved image gallery widget; Improved generateHTML function