Fixed some bugs related to mouse events.