Refactor Format handling

Move Format string handling into a class for use by READ. This
simplifies the logic considerably.