Added count(), improved performances of min_id() and max_id(), and
added overloads of min() and max() that store the id in a second
argument.