Main window configuration and main loop