Fixes issues #109 and #114, related to a memory leak in query transactions