Code refactoring. Minor issues fix