Implemented MainWindow.Sanitize() method (courtesy of nodeleaf).