Fixed Tim's bug. The cursor is now set correctly in all cases.