Clean up some thing.  Implement logging history.

Also implemented countgen interface.