Cursors are now properly closed, fixes #1