Fix some permissions bugs