Made the transactional database functions accept an optional external transaction.