Improved the flash_device script.