Implement Permissions checks into Core

I may have missed some spots...
I don't understand the relationship between permission and perm in this function exactly, but this can't be what you meant :P