Initial version of a GUI. More rebalancing. Some refactoring.