HOPKINS: Some refactoring in the pathfinding code