fix gallery bugs