Implementation of class-based permission system

Implements #16 and fixes #18