Refactor format-related stuff into own module