Fix & refactor permissions checking (fixes #75, fixes #88)

This has the added benefit of condensing the code that needs to understand tags, so the transition to permissions will be easier.