Bugfixes for reopening of mainWindow