refactor synchronization in to smaller helper methods
further refactor to move synchronization into smaller helper methods.
Refactored PermissionHandler to be an abstract class so that it can have implemented methods. Added the switchGroup method to the PermissionHandler abstract class.
Refactored maybeSwitchRegistered to use the new switchGroup method.
fix to remove former pseudo-primary group when adding a new one. Fixes #81.