Restructured set_formatting to be split up to smaller functions.