Some refactoring and UI fiddling.