Ugly fix for bug in implementation of Dijkstra's alg