Threading with db transactions is not easy: got several 'db locked'/timeout errors in prior version so switching how commits are managed slightly.