Security fixes, more checks to prevent code injection. Documentation update on
writing system wrapper scripts (including security notes).