Important performance improvement made in heuristic function