Functional base for invitations and some refactoring