if permission check fails, close stream
removed static from tfs and removed hardcoded constant in common
Merge pull request #498 from dcapwell/morefindbugs

Morefindbugs