improved galleries functionality