Gui fix, optimization, refactoring.