Perform refactoring of distances representation
Perform minor refactoring