refactored code. added classes for several parts of ui.