Complete refactoring of the mouse state handeling