Added extra checks to group perms on exit