Use dict style access on events
Refactor flip

* Change argument names to better describe their usage
* Pull logic out into reuasable function