Improved MaxSize logic in DialogViewer.