Bugfixes for permission