Reinstate ignore permissions
Refactor out functions in main