Added cursor closing debugging messages.
Try using thread local variables to fix the threaded cursor issues.