Stopped passing the cursor around in functions as there were too many functions that didn't need it