Refactoring code; separate State and Gui classes.