Improved code quality reducing redundancies.
Fixed selected items handling.