Added permission checking. Closes #36
Added permission checks.