This should probably happen in a transaction.