Improve distance algorithm

Add a more reliable count factor. I'm still unsure if
its impact should be minimized by power of 2.
It needs more feedback ;)