Fixed a bug in calculating permissions while impersonating. Fixes #144.