[DF-3836] Fix memory leaks. Replace absolute pathes with relative. Small refactoring