fixes #119 where clients could lock themselves out of their own resources
fixed #81 & #115
fixed test
Merge pull request #120 from evillemez/fix-115

Fixed several things