Cleaned up template code.