Security cleanup

This contains my suggestions for the security configuration. Each commit has fairly detailed explanation, but if anything doesn't make sense please let me know.