Improved mouse coordinates calculation.