UI tweaks and code refactoring.
