Refactored controller event handling.