Added role checking code and cleaned up config