added no-flag support. Added another heuristic.