Improved cursor placement and refactored mousex computation