Groups user lost after saving

When a user changes his profile, the groups data are lost because before saving the new data, the group is set to null.

I propose to save the group before saving and restore it after.