Refactoring of dialog, template caching, and template rendering in preperation for a popup component