Changes to UI and refactoring code