More work on rewriting the main window