Changed function for mousePos. Did some cleaning.