Fixes after CR

Additionally:
Distance comparision method changed to more precise one without performance degradation.
I'm so sorry.... Not, finally this time has come ;)