Added Controller class and flush event on window close.
Corrected conflicts