Clean the thumbnail generation code