Some bugfixes, permission checking complete.