Changes to fix issues with versions
Abstracting template system, plus cleanup (untested)