Paranoia: Made sure all cursors will get disposed of in a finally block.
Converted tabs to spaces.
Merge pull request #363 from jonlipsky/issue-348

Made sure all cursors would be disposed in a finally block.