Added role security function and made other tweaks