Some small template bug fixes