Fix destruction order