Improve performance of permissions related methods and functions.

it looks to me like this should be Permission.set_grants_permission(), and also have its return value checked. I'd really like to have enough automated testing to cover this sort of thing