Refactor events model and controller