Move some messy code from the view to the AclManager, and rename some functions.