Fixed a few more template bugs