fix bugs in A* and in the 2d implementation