refactor replace_template_colors

NOT WORKING YET. But the basic reorganization is there. Just need to
tweak to get working again. Further refactoring will probably happen.

Notice messages.py taking the long strings from replace_template_colors