Improved error handling.
Removed application of the cursor to the window.
Removed cursor creation code.