Better handling of cursors by reusing a cursor if it is open and properly closing one when it is no longer in use.