Refactored graph stuff out of main window