MISC security fixes

Stuff that I've had for ages locally... and that should probably get in the next release.
And it shouldn't. https://wiki.freenetproject.org/Coding_style