Refactoring of ImageWindow and mainWindow