Separate out mouse utility functions into new module. Other small tweaks.