Restructure cursor handling and add support for legacy cursors