Quick refactor to make it easy to add other output formats.