logic looks exactly the same as the working pathfinder commit but the
result is totally different (getting ASSERT failure). still trying to
debug.