Enhanced to save thumbnails.