Improve formatting logic.