Optimize UI dialog
Dialog optimization: .detach() before wrapping