Permissions API bugfixes