Ui refactor

I split this up into several commits. Cherry pick as needed.

Lots more UI refactoring to come.