Add serial_num/connection_id handling and save/restore last device