Significant changes.  Now uses templating.