Rewrite and improve formatted output routines.