Implemented most of the UI.