hand-merge some changes from brute branch
updates to heuristic