Fix some issues in the event listeners.