Fix various template issues