Permission rewrite

Rewrote a log of permissions, Had to fix a lot of bugs