Externalized GUI code and connected it to the mode