Bug fix: cursor management