added MissingPrivilegesException
minor fixes
code cleanup