This is the one code change.  This is fine in production, but messy in tests, and less failsafe in production (though if you're deleting Device.own_device, you may be in trouble anyway).