fix problem and device cleanup