Fixed get_permissions
A few macro tweaks

and added the secondary_groups field to the templates