Several small modifications and make the permission model saved in the database (not yet tested to see if it works)