Fix leaking transaction groups locks and transactions