Refactored mouse input handlers.