refactored settings and added AD code for use