Added conditional detachment from parent in BaseAction::Cleanup