Refactor ui wiring and APIs