new heuristic, mem bug fix