Make the cursor an iterator, fix lots of stuff