Switch events.flush to events.remove to ensure we only remove the right handler