Fixed bugs and refactoring gallery_models