Fix bugs for updating permissions