Move storing device to after unlock, eliminate duplicates in file