Refactored event listeners.