Fixed bugs in permission checking.
Improved PermissionsListWriter.