Fixes #930 by wrapping delete in a transaction.