Initial version that writes final table
Still untested other than a very broad does the output look like I expect it to