Refactor to decouple drawing from Astar algorithm