Fixes after CR

Additionally:
Distance comparision method changed to more precise one without performance degradation.
you can use `Function.prototype` instead of noop