Removed debug code.
Simplified permissions setting.