more template refactors.  apparently my bash-blob fu was too weak.