Fixed bugs in gallery module