Fixed a bug with the navmesh's edges. Optimized end of path detection