fixed a memory leak when using transactions