Feature permissions

Permission form is now working, and some other permission related problems have been fixed. This branch can be deleted after merging.