No more leaks. Fixed the flawed logic in device_change.