Fixed problem with recreating  the main window.