Remove legacy permission code
Add missing folder closing statement