Permission rewrite

Rewrote a log of permissions, Had to fix a lot of bugs
Merge pull request #6 from pinoniq/Permission-rewrite

Permission rewrite