Essentially working A*.