Fixed so user get correct priviligies (all the different groups he belongs to). And changed the code to adapt to this