Refactoring the UI code.