Fixed distance calculation, re-written unoptimal code
changed splitting logic a bit
Merge pull request #2 from thousandsofthem/master

Fixed distance calculation, Re-written unoptimal code