LUN-819 -- some refactoring