TMDM-7517: code refactoring and clean-ups