Added some sanity checking for the mouse coordinates.