Pull request for security and weirdness

I consider the definition security hole slightly above-average importance, but it's nothing that requires an ASAP pull or anything, you'd have to mess up command scripts a fair bit to expose the hole, in theory.
Other stuff is minor.