Refactor the FormatWriter class.