Refactor functions for setting UI.