shortest_path method and several fixes