Fixed bugs in generating smaller thumbnails