Code refactoring in Gui module