Fix handling of permissions, fixes #80