added some portions of beta_invite machinery