Cleaning up repeated code in templates.
Removed unneeded keywords
Copied relevant changes from PR #66