Split the ToString function up to reduce future code duplication.