Fixed a nasty bug with nested transactions.