Refactoring: simplified render_gallery_for method, some of its code moved to Configurator class.