Several updates and changes.

-Changed how permissions are done, now done through "role" attribute of user.
-Updated error handling for 401, 404 and 500
-Enabled logging.