Merge pull request #165 from Bowman74/master

 #162 fixed problem with code that adds extra permission records
Merge pull request #43 from Magenic/master

Merging into my local fork.
Fixing issue #166
Fixing issue #163
Merge pull request #167 from jwendl/master

Fixing issues.
Merge pull request #41 from Magenic/master

Merge from master