Tidied up format() a bit.

(Removed flags string in favor of setting boolean values in loop)