spin off code to security and branding plugins

Easier to debug. Also commented in admin