Bug fixes for permissions