Path algorithm finally working.