decoupled dialog from AppView, tweaked some template related code