Fixed some more errors due to rebasing. Also fixed some queries in invite model