Change shortest path code slightly.