Some security fixes

Not everything is fixed, but many things are.