Fix loop counters in included templates

This should resolve #16