Refactor the GUI building