Fixed cleanup procedure