Added perms, cleaned code, fixed bugs.

Drtshock is my best friend.