Refactor parts of UI