EMI: Rework attaching and detaching.