gallery: fix bugs