Refactor started.
Refactor ui background script.