Separate World and MainWindow

Fix: frame counting bug when reallocation is unnecessary.
Change: separate World into World and MainWindow.
Change: refactor code and fix typos.