Divide gui and logic. Refactoring.