First step toward graphical mode.
* Refactoring: move graphical code to its own class.
* Fix graphical exit code.