Fixed bug in permission system. Fixes #1094