Moved mouse expand module code to its own function.