Implement more generic version of gallery.