Remove duplicated code

Introduce update_stats() and remove correspondng
duplicated code.

No functional change.
Merge branch 'master' into play_nth_best_move
fixes
style