Updating permission models.

Beautifying code and adding functionality.