Rewrote the permissions system.
It is now simpler to understand and has less code associated with its
different methods.