Rationalize the permissions system.
Bug fixes