Better permissions error handling + bugfixes