Added role handling and fixed namespace issues.