refactor event model handling of state. add logging.