Refactor out the outfiles