Sorted out a few issues with templates