added new user interface features and logic, plus refactoring.