Small tweaks to generalize the template.

Here is the pull request you asked for with the changes made. I use this frequently. Nice work.