Fix a couple of spots in the handling of device states that could lead to a