Device save/restore: handle more non-existing keys and whitespace fix