See #161: Corrected permissions for multiple wildcards from Loren's code.  Corrected some other security related functions.