Refactor template code to be more flexible

Major refactoring to use the new template code,
Updated credits file to reflect Glenn's work,
Clean up some file headers