Add heuristic functions.
Merge branch 'heuristics'