Fix for U4-1285: Apostrophes in member groups cause exceptions

This pull request contains 3 fixes for related issues caused by member groups having an apostrophe in the name - allowing them to be created, renamed and deleted.

I'm afraid as before I can't find a away to remove from this pull request a commit that was submitted for another pull request - hence for this you should only take the last two commits and ignore the first one (426131739cee1ea458c0dca979eb2ffb0f0e349c).  Hope that's OK.