restructured program

fixed errors in true win rate calculation, reordered functions for
clarity