moved flipCount to model, added event history, refactored some code