TMDM-7478: code clean-up and refactoring