start refactoring window, grid and main