Refactored invite-related functions to their own files