Fixed invitations some more.

Now invitations work more or less as expected but this has to be tested for a large number of marginal cases.