Code clean-up
More correct handling of invitations