Synchronize access to cursor.
Fixes #42