Revised ui

It's ready to merge. The structure of UI code was changed so that it's more maintainable.