Refactored all authorization-specific stuff.