Misc sec fixes

A few fixes for making security manager work a bit more smoothly.