Do some refactoring and create the basic api functions for the gui component.