thumbnails and refactoring of gallery