Merge pull request #251 from nhr/file_handling_updates

Some dir ensure / file security checks